Class B2ByteArrayContentSource
- java.lang.Object
-
- com.backblaze.b2.client.contentSources.B2ByteArrayContentSource
-
- All Implemented Interfaces:
B2ContentSource
public class B2ByteArrayContentSource extends java.lang.Object implements B2ContentSource
Use B2ByteArrayContentSource to wrap data in memory for uploading to B2. Don't change the data while it's being uploaded. If you know the sha1, you're encouraged to provide it. See B2ContentSource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
B2ByteArrayContentSource.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static B2ContentSource
build(byte[] bytes)
static B2ByteArrayContentSource.Builder
builder(byte[] bytes)
java.io.InputStream
createInputStream()
NOTE: this may be called multiple times as uploads are retried, etc.long
getContentLength()
java.lang.String
getSha1OrNull()
You are encouraged to implement this.java.lang.Long
getSrcLastModifiedMillisOrNull()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.backblaze.b2.client.contentSources.B2ContentSource
createContentSourceWithRangeOrNull
-
-
-
-
Method Detail
-
build
public static B2ContentSource build(byte[] bytes)
-
builder
public static B2ByteArrayContentSource.Builder builder(byte[] bytes)
-
getSha1OrNull
public java.lang.String getSha1OrNull() throws java.io.IOException
Description copied from interface:B2ContentSource
You are encouraged to implement this. If it returns non-null, the B2Client can provide the sha1 before performing the upload. Definitely implement this if you've stored the sha1 separately from the file. That way you can ensure that B2 doesn't take the file if there's trouble reading it from your source. If you return null, B2StorageClient will compute the SHA1 from the bytes in the stream. Note that large files do not have SHA-1s for the entire file. If you provide a SHA-1 for a large file upload, the SDK follows the recommendation of putting your value into the 'large_file_sha1' fileInfo. See "SHA1 Checksums" in https://www.backblaze.com/b2/docs/large_files.html- Specified by:
getSha1OrNull
in interfaceB2ContentSource
- Returns:
- the hex-encoded sha1 for the content or null if it's not known yet.
- Throws:
java.io.IOException
- if there's trouble
-
getSrcLastModifiedMillisOrNull
public java.lang.Long getSrcLastModifiedMillisOrNull() throws java.io.IOException
- Specified by:
getSrcLastModifiedMillisOrNull
in interfaceB2ContentSource
- Returns:
- the time the source was last modified (in milliseconds since the epoch) or null if there isn't a reasonable value for that.
- Throws:
java.io.IOException
- if there's trouble
-
getContentLength
public long getContentLength() throws java.io.IOException
- Specified by:
getContentLength
in interfaceB2ContentSource
- Returns:
- the number of bytes in the content. the length must be non-negative.
- Throws:
java.io.IOException
- if there's trouble
-
createInputStream
public java.io.InputStream createInputStream() throws java.io.IOException
Description copied from interface:B2ContentSource
NOTE: this may be called multiple times as uploads are retried, etc. The content is expected to be identical each time this is called.- Specified by:
createInputStream
in interfaceB2ContentSource
- Returns:
- a new inputStream containing the contents.
- Throws:
java.io.IOException
- if there's trouble
-
-