Class B2FileContentSource

    • Method Detail

      • 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 interface B2ContentSource
        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 interface B2ContentSource
        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 interface B2ContentSource
        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 interface B2ContentSource
        Returns:
        a new inputStream containing the contents.
        Throws:
        java.io.IOException - if there's trouble