Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fileName member to TypedByteArray #902

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion retrofit/src/main/java/retrofit/mime/TypedByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,31 @@
public class TypedByteArray implements TypedInput, TypedOutput {
private final String mimeType;
private final byte[] bytes;
private final String fileName;

/**
* Constructs a new typed byte array. Sets mimeType to {@code application/unknown} if absent.
*
* @throws NullPointerException if bytes are null
*/
public TypedByteArray(String mimeType, byte[] bytes, String fileName) {
if (mimeType == null) {
mimeType = "application/unknown";
}
if (bytes == null) {
throw new NullPointerException("bytes");
}
this.mimeType = mimeType;
this.bytes = bytes;
this.fileName = fileName;
}

/**
* Constructs a new typed byte array. Sets mimeType to {@code application/unknown} if absent.
* Sets fileName to null
*
* @throws NullPointerException if bytes are null
*/
public TypedByteArray(String mimeType, byte[] bytes) {
if (mimeType == null) {
mimeType = "application/unknown";
Expand All @@ -44,14 +63,15 @@ public TypedByteArray(String mimeType, byte[] bytes) {
}
this.mimeType = mimeType;
this.bytes = bytes;
this.fileName = null;
}

public byte[] getBytes() {
return bytes;
}

@Override public String fileName() {
return null;
return fileName;
}

@Override public String mimeType() {
Expand Down