public final class Blob extends Object implements com.couchbase.lite.internal.fleece.FLEncodable
Constructor and Description |
---|
Blob(String contentType,
byte[] content)
Construct a Blob with the given in-memory data.
|
Blob(String contentType,
InputStream stream)
Construct a Blob with the given stream of data.
|
Blob(String contentType,
URL fileURL)
Construct a Blob with the content of a file.
|
Modifier and Type | Method and Description |
---|---|
String |
digest()
The cryptographic digest of this Blob's contents, which uniquely identifies it.
|
void |
encodeTo(com.couchbase.lite.internal.fleece.FLEncoder encoder) |
boolean |
equals(Object o)
Compare for equality.
|
byte[] |
getContent()
Gets the contents of this blob as in in-memory byte array.
|
InputStream |
getContentStream()
Get a the contents of this blob as a stream.
|
String |
getContentType()
Return the type of of the content this blob contains.
|
Map<String,Object> |
getProperties()
Get the blob metadata
|
int |
hashCode()
Get the blob hash code.
|
long |
length()
The number of byte of content this blob contains.
|
String |
toString()
Returns a string representation of the object.
|
public Blob(@NonNull String contentType, @NonNull byte[] content)
contentType
- The type of content this Blob will representcontent
- The data that this Blob will containpublic Blob(@NonNull String contentType, @NonNull InputStream stream)
getContent
) or to the database.
If it is closed before that, by client code, the attempt to store the blob will fail.
The converse is also true: the stream for a blob that is not saved or copied to memory
will not be closed (except during garbage collection).contentType
- The type of content this Blob will representstream
- The stream of data that this Blob will consumepublic Blob(@NonNull String contentType, @NonNull URL fileURL) throws IOException
contentType
- The type of content this Blob will representfileURL
- A URL to a file containing the data that this Blob will represent.IOException
- on failure to open the file URL@Nullable public byte[] getContent()
@Nullable public InputStream getContentStream()
@NonNull public String getContentType()
public long length()
@Nullable public String digest()
@NonNull public Map<String,Object> getProperties()
public void encodeTo(@NonNull com.couchbase.lite.internal.fleece.FLEncoder encoder)
encodeTo
in interface com.couchbase.lite.internal.fleece.FLEncodable
@NonNull public String toString()
public int hashCode()
public boolean equals(Object o)