Package com.restfb
Class BinaryAttachment
java.lang.Object
com.restfb.BinaryAttachment
- Direct Known Subclasses:
FacebookReelAttachment
Represents a binary file that can be uploaded to Facebook.
Normally this would be a photo or video.
- Since:
- 1.6.5
- Author:
- Mark Allen, Marcel Stoer
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedBinaryAttachment(String filename, byte[] data) Creates a new binary attachment.protectedBinaryAttachment(String filename, byte[] data, String contentType) Creates a new binary attachment.protectedBinaryAttachment(String fieldName, String filename, byte[] data) Creates a new binary attachment.protectedBinaryAttachment(String fieldName, String filename, byte[] data, String contentType) Creates a new binary attachment.protectedBinaryAttachment(String fieldName, String filename, Supplier<InputStream> dataSupplier) Creates a new binary attachment backed by a stream supplier.protectedBinaryAttachment(String fieldName, String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a new binary attachment backed by a stream supplier.protectedBinaryAttachment(String filename, Supplier<InputStream> dataSupplier) Creates a new binary attachment backed by a stream supplier.protectedBinaryAttachment(String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a new binary attachment backed by a stream supplier. -
Method Summary
Modifier and TypeMethodDescriptionbooleanreturn the given content type or try to guess from stream or file name.getData()The attachment's data.Returns the form field name used for multipart uploads.booleaninthashCode()booleantoString()static BinaryAttachmentCreates a binary attachment.static BinaryAttachmentCreates a binary attachment.static BinaryAttachmentCreates a binary attachment.static BinaryAttachmentCreates a binary attachment.static BinaryAttachmentwith(String fieldName, String filename, Supplier<InputStream> dataSupplier) Creates a binary attachment backed by a stream supplier.static BinaryAttachmentCreates a binary attachment backed by a stream supplier.static BinaryAttachmentwith(String filename, Supplier<InputStream> dataSupplier) Creates a binary attachment backed by a stream supplier.static BinaryAttachmentwith(String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a binary attachment backed by a stream supplier.
-
Field Details
-
data
-
-
Constructor Details
-
BinaryAttachment
protected BinaryAttachment() -
BinaryAttachment
Creates a new binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
BinaryAttachment
Creates a new binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.fieldName- The field name the binary belongs to- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
BinaryAttachment
Creates a new binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.contentType- The attachment's contentType.- Throws:
IllegalArgumentException- IfdataSupplierisnull,filenameisnullor blank, orcontentTypeisnullor blank.- Since:
- 1.6.13
-
BinaryAttachment
protected BinaryAttachment(String fieldName, String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a new binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.contentType- The attachment's contentType.fieldName- The field name the binary belongs to- Throws:
IllegalArgumentException- IfdataSupplierisnull,filenameisnullor blank, orcontentTypeisnullor blank.- Since:
- 1.6.13
-
BinaryAttachment
Creates a new binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
BinaryAttachment
Creates a new binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.fieldName- The field name the binary belongs to- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
BinaryAttachment
Creates a new binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.contentType- The attachment's contentType.- Throws:
IllegalArgumentException- Ifdataisnull,filenameisnullor blank, orcontentTypeisnullor blank.- Since:
- 1.6.17
-
BinaryAttachment
Creates a new binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.contentType- The attachment's contentType.fieldName- The field name the binary belongs to- Throws:
IllegalArgumentException- Ifdataisnull,filenameisnullor blank, orcontentTypeisnullor blank.- Since:
- 1.6.17
-
-
Method Details
-
isFacebookReel
-
with
Creates a binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
with
public static BinaryAttachment with(String fieldName, String filename, Supplier<InputStream> dataSupplier) Creates a binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.fieldName- The field name the binary belongs to- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
with
public static BinaryAttachment with(String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.contentType- The attachment's contentType.- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
with
public static BinaryAttachment with(String fieldName, String filename, Supplier<InputStream> dataSupplier, String contentType) Creates a binary attachment backed by a stream supplier.- Parameters:
filename- The attachment's filename.dataSupplier- Provides a freshInputStreamfor each access.fieldName- The field name the binary belongs tocontentType- The attachment's contentType.- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- IfdataSupplierisnullorfilenameisnullor blank.
-
with
Creates a binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
with
Creates a binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.fieldName- The field name the binary belongs to- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
with
Creates a binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.contentType- The attachment's contentType.- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
with
public static BinaryAttachment with(String fieldName, String filename, byte[] data, String contentType) Creates a binary attachment.- Parameters:
filename- The attachment's filename.data- The attachment's data.contentType- The attachment's contentType.fieldName- The field name the binary belongs to- Returns:
- A binary attachment.
- Throws:
IllegalArgumentException- Ifdataisnullorfilenameisnullor blank.- Since:
- 1.6.17
-
hashCode
-
equals
-
toString
-
getData
The attachment's data.- Returns:
- The attachment's data.
-
getContentType
return the given content type or try to guess from stream or file name. Depending of the available data.- Returns:
- the content type
-
hasBinaryData
-
getFormFieldName
Returns the form field name used for multipart uploads.- Returns:
- the explicit field name if set, otherwise the filename without its extension
-
getFilename
-
getFieldName
-