Package com.couchbase.lite.internal.core
Class C4BlobWriteStream
- java.lang.Object
-
- com.couchbase.lite.internal.core.C4NativePeer
-
- com.couchbase.lite.internal.core.C4BlobWriteStream
-
- All Implemented Interfaces:
AutoCloseable
public class C4BlobWriteStream extends C4NativePeer
An open stream for writing data to a blob.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes a blob write-stream.C4BlobKey
computeBlobKey()
Computes the blob-key (digest) of the data written to the stream.void
install()
Adds the data written to the stream as a finished blob to the store.void
write(byte[] bytes)
Writes an entire byte array to the stream.void
write(byte[] bytes, int len)
Writes the len bytes from the passed array, to the stream.-
Methods inherited from class com.couchbase.lite.internal.core.C4NativePeer
toString
-
-
-
-
Method Detail
-
write
public void write(@NonNull byte[] bytes) throws LiteCoreException
Writes an entire byte array to the stream.- Parameters:
bytes
- array of bytes to be written in its entirety- Throws:
LiteCoreException
- on write failure
-
write
public void write(@NonNull byte[] bytes, int len) throws LiteCoreException
Writes the len bytes from the passed array, to the stream.- Parameters:
bytes
- array of bytes to be written in its entirety.len
- the number of bytes to write- Throws:
LiteCoreException
- on write failure
-
computeBlobKey
@NonNull public C4BlobKey computeBlobKey() throws LiteCoreException
Computes the blob-key (digest) of the data written to the stream. This should only be called after writing the entire data. No more data can be written after this call.- Throws:
LiteCoreException
-
install
public void install() throws LiteCoreException
Adds the data written to the stream as a finished blob to the store. If you skip this call, the blob will not be added to the store. (You might do this if you were unable to receive all of the data from the network, or if you've called c4stream_computeBlobKey and found that the data does not match the expected digest/key.)- Throws:
LiteCoreException
-
close
@CallSuper public void close()
Closes a blob write-stream. If c4stream_install was not already called, the temporary file will be deleted without adding the blob to the store.
-
-