Class B2StorageClientImpl

  • All Implemented Interfaces:
    B2StorageClient, java.io.Closeable, java.lang.AutoCloseable

    public class B2StorageClientImpl
    extends java.lang.Object
    implements B2StorageClient
    B2StorageClientImpl implements B2StorageClient and it acquires credentials as needed and implements our retry policies. It's also smart about using other threads to help with the uploads. THREAD-SAFETY: As long at the subobjects it's given are thread-safe, this object may be used from multiple threads simultaneously.
    • Constructor Detail

      • B2StorageClientImpl

        public B2StorageClientImpl​(B2StorageClientWebifier webifier,
                                   B2ClientConfig config,
                                   java.util.function.Supplier<B2RetryPolicy> retryPolicySupplier)
        Creates a client with the given webifier and config and a default B2Sleeper. This is the normal constructor.
        Parameters:
        webifier - the object to convert API calls into web calls.
        config - the object used to configure this.
    • Method Detail

      • close

        public void close()
        Closes resources used by this client. It's safe to call when it's already been called. It won't return until we've tried to close the resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface B2StorageClient
        Specified by:
        close in interface java.io.Closeable
      • applicationKeys

        public B2ListKeysIterable applicationKeys​(B2ListKeysRequest request)
                                           throws B2Exception
        Description copied from interface: B2StorageClient
        Returns an iterable whose iterator yields the application keys that match the given request. It will automatically call B2 to get batches of answers as needed. If there's any trouble during hasNext() or next(), it will throw a B2RuntimeException since Iterable<> doesn't allow checked exceptions to be thrown.
        Specified by:
        applicationKeys in interface B2StorageClient
        Parameters:
        request - specifies which application keys to list.
        Returns:
        a new iterable to iterate over fileVersions that match the given request.
        Throws:
        B2Exception - if there's any trouble
      • finishUploadingLargeFile

        public B2FileVersion finishUploadingLargeFile​(B2FileVersion fileVersion,
                                                      B2UploadFileRequest request,
                                                      java.util.concurrent.ExecutorService executor)
                                               throws B2Exception
        Description copied from interface: B2StorageClient
        Verifies that the given fileVersion represents an unfinished large file and that the specified content is compatible-enough with the information in that B2FileVersion. If it is, this will find the parts that haven't yet been uploaded and upload them to finish the large file. XXX: describe "compatible-enough". basically it's some sanity checks such as the size of the content and the large-file-sha1 if it's available. just enough to believe the request probably does go with the presented fileVersion. (Note that if you make up a bogus fileVersion, you're on your own!)
        Specified by:
        finishUploadingLargeFile in interface B2StorageClient
        Parameters:
        fileVersion - describes the unfinished large file we want to finish.
        request - describes the content we want to use to finish the large file
        executor - the executor to use for uploading parts in parallel. the caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        the B2FileVersion that represents the finished large file.
        Throws:
        B2Exception - if there's any trouble.
      • uploadSmallFile

        public B2FileVersion uploadSmallFile​(B2UploadFileRequest request)
                                      throws B2Exception
        Description copied from interface: B2StorageClient
        Uploads the specified content as a normal B2 file. The file must be smaller than the maximum file size (5 GB).
        Specified by:
        uploadSmallFile in interface B2StorageClient
        Parameters:
        request - describes the content to upload and extra metadata about it.
        Returns:
        the B2FileVersion that represents it.
        Throws:
        B2Exception - if there's any trouble.
      • copySmallFile

        public B2FileVersion copySmallFile​(B2CopyFileRequest request)
                                    throws B2Exception
        Description copied from interface: B2StorageClient
        Makes a copy of a file in the same bucket. The new file must be smaller than the maximum file size (5 GB).
        Specified by:
        copySmallFile in interface B2StorageClient
        Parameters:
        request - describes what file to copy, the range of bytes to copy, and how to handle file metadata.
        Returns:
        The B2FileVersion of the new file.
        Throws:
        B2Exception - if there's any trouble.
      • uploadLargeFile

        public B2FileVersion uploadLargeFile​(B2UploadFileRequest request,
                                             java.util.concurrent.ExecutorService executor)
                                      throws B2Exception
        Description copied from interface: B2StorageClient
        Uploads the specified content as separate parts to form a B2 large file.
        Specified by:
        uploadLargeFile in interface B2StorageClient
        Parameters:
        request - describes the content to upload and extra metadata about it.
        executor - the executor to use for uploading parts in parallel. the caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        the B2FileVersion that represents it.
        Throws:
        B2Exception - if there's any trouble.
      • storeLargeFileFromLocalContent

        public B2FileVersion storeLargeFileFromLocalContent​(B2FileVersion fileVersion,
                                                            B2ContentSource contentSource,
                                                            B2UploadListener uploadListener,
                                                            java.util.concurrent.ExecutorService executor)
                                                     throws B2Exception
        Description copied from interface: B2StorageClient
        Uploads the specified content source as separate parts to form a B2 large file. This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method. However, this method will call finish file. XXX: add storePartsForLargeFileFromLocalContent that stores parts but doesn't finish the file.
        Specified by:
        storeLargeFileFromLocalContent in interface B2StorageClient
        Parameters:
        fileVersion - The B2FileVersion for the large file getting stored. This is the return value of startLargeFile().
        contentSource - The contentSource to upload.
        uploadListener - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The fileVersion of the large file after it has been finished.
        Throws:
        B2Exception - If there's trouble.
      • storeLargeFileFromLocalContent

        public B2FileVersion storeLargeFileFromLocalContent​(B2StoreLargeFileRequest storeLargeFileRequest,
                                                            B2ContentSource contentSource,
                                                            B2UploadListener uploadListener,
                                                            java.util.concurrent.ExecutorService executor)
                                                     throws B2Exception
        Description copied from interface: B2StorageClient
        Uploads the specified content source as separate parts to form a B2 large file, optionally allowing caller to pass SSE-C parameters to match those given to startLargeFile(). This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method as part of a B2StoreLargeFileRequest. However, this method will call finish file. XXX: add storePartsForLargeFileFromLocalContent that stores parts but doesn't finish the file.
        Specified by:
        storeLargeFileFromLocalContent in interface B2StorageClient
        Parameters:
        storeLargeFileRequest - The B2StoreLargeFileRequest for the large file getting stored. This is built from the return value of startLargeFile() and any other relevant parameters.
        contentSource - The contentSource to upload.
        uploadListener - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The fileVersion of the large file after it has been finished.
        Throws:
        B2Exception - If there's trouble.
      • storeLargeFileFromLocalContentAsync

        public java.util.concurrent.CompletableFuture<B2FileVersion> storeLargeFileFromLocalContentAsync​(B2FileVersion fileVersion,
                                                                                                         B2ContentSource contentSource,
                                                                                                         B2UploadListener uploadListenerOrNull,
                                                                                                         java.util.concurrent.ExecutorService executor)
                                                                                                  throws B2Exception
        Description copied from interface: B2StorageClient
        Initiates uploading the specified content source as separate parts to form a B2 large file. This allows the upload to be cancelled partway through. This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method. The returned future can be cancelled and this will also attempt to stop any part uploads in progress. Cancelling after the b2_finish_large_file API call has been started will result in the future being cancelled, but the API call can still succeed. There is no way to tell from the future whether this is the case. The caller is responsible for checking and calling B2StorageClient.cancelLargeFile.
        Specified by:
        storeLargeFileFromLocalContentAsync in interface B2StorageClient
        Parameters:
        fileVersion - The B2FileVersion for the large file getting stored. This is the return value of startLargeFile().
        contentSource - The contentSource to upload.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        CompletableFuture with the resulting B2FileVersion of the completed file
        Throws:
        B2Exception - on error
      • storeLargeFileFromLocalContentAsync

        public java.util.concurrent.CompletableFuture<B2FileVersion> storeLargeFileFromLocalContentAsync​(B2StoreLargeFileRequest storeLargeFileRequest,
                                                                                                         B2ContentSource contentSource,
                                                                                                         B2UploadListener uploadListenerOrNull,
                                                                                                         java.util.concurrent.ExecutorService executor)
                                                                                                  throws B2Exception
        Description copied from interface: B2StorageClient
        Initiates uploading the specified content source as separate parts to form a B2 large file. This allows the upload to be cancelled partway through. This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method. The returned future can be cancelled and this will also attempt to stop any part uploads in progress. Cancelling after the b2_finish_large_file API call has been started will result in the future being cancelled, but the API call can still succeed. There is no way to tell from the future whether this is the case. The caller is responsible for checking and calling B2StorageClient.cancelLargeFile.
        Specified by:
        storeLargeFileFromLocalContentAsync in interface B2StorageClient
        Parameters:
        storeLargeFileRequest - The B2StoreLargeFileRequest for the large file getting stored. This is built from the return value of startLargeFile() and any other relevant parameters.
        contentSource - The contentSource to upload.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        CompletableFuture with the resulting B2FileVersion of the completed file
        Throws:
        B2Exception - on error
      • storeLargeFile

        public B2FileVersion storeLargeFile​(B2FileVersion fileVersion,
                                            java.util.List<B2PartStorer> partStorers,
                                            B2UploadListener uploadListenerOrNull,
                                            java.util.concurrent.ExecutorService executor)
                                     throws B2Exception
        Description copied from interface: B2StorageClient
        Stores a large file, where storing each part may involve different behavior or byte sources.

        For example, this method supports the use case of making a copy of a file that mostly has not changed, and the user only wishes to upload the parts that have changed. In this case partStorers would be a mix of B2CopyingPartStorers and one or more B2UploadingPartStorers.

        Another use case would be reattempting an upload of a large file where some parts have completed, and some haven't. In this case, partStorers would be a mix of B2AlreadyStoredPartStorer and B2UploadingPartStorers.

        This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method. However, this method will call finish file. Note that each part, whether copied or uploaded, is still subject to the minimum part size.

        Specified by:
        storeLargeFile in interface B2StorageClient
        Parameters:
        fileVersion - The B2FileVersion for the large file getting stored. This is the return value of startLargeFile().
        partStorers - The list of objects that know how to store the part they are responsible for.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The fileVersion of the large file after it has been finished.
        Throws:
        B2Exception - If there's trouble.
      • storeLargeFile

        public B2FileVersion storeLargeFile​(B2StoreLargeFileRequest storeLargeFileRequest,
                                            java.util.List<B2PartStorer> partStorers,
                                            B2UploadListener uploadListenerOrNull,
                                            java.util.concurrent.ExecutorService executor)
                                     throws B2Exception
        Description copied from interface: B2StorageClient
        Stores a large file, where storing each part may involve different behavior or byte sources, optionally allowing caller to pass SSE-C parameters to match those given to startLargeFile().

        For example, this method supports the use case of making a copy of a file that mostly has not changed, and the user only wishes to upload the parts that have changed. In this case partStorers would be a mix of B2CopyingPartStorers and one or more B2UploadingPartStorers.

        Another use case would be reattempting an upload of a large file where some parts have completed, and some haven't. In this case, partStorers would be a mix of B2AlreadyStoredPartStorer and B2UploadingPartStorers.

        This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method as part of a B2StoreLargeFileRequest. However, this method will call finish file. Note that each part, whether copied or uploaded, is still subject to the minimum part size.

        Specified by:
        storeLargeFile in interface B2StorageClient
        Parameters:
        storeLargeFileRequest - The B2StoreLargeFileRequest for the large file getting stored. This is built from the return value of startLargeFile() and any other relevant parameters.
        partStorers - The list of objects that know how to store the part they are responsible for.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The fileVersion of the large file after it has been finished.
        Throws:
        B2Exception - If there's trouble.
      • storePartsForLargeFile

        public java.util.List<B2Part> storePartsForLargeFile​(B2FileVersion fileVersion,
                                                             java.util.List<B2PartStorer> partStorers,
                                                             B2UploadListener uploadListenerOrNull,
                                                             java.util.concurrent.ExecutorService executor)
                                                      throws B2Exception
        Description copied from interface: B2StorageClient
        Stores large file parts, where storing each part may involve different behavior or byte sources.

        For example, this method supports the use case of preparing to make a copy of a file that mostly has not changed, and the user only wishes to upload the parts that have changed. In this case partStorers would be a mix of B2CopyingPartStorers and one or more B2UploadingPartStorers.

        Another use case would be reattempting some part uploads for an unfinished large file for which some parts have completed, and some haven't. In this case, partStorers would be a mix of B2AlreadyStoredPartStorer and B2UploadingPartStorers.

        This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method. Note that each part, whether copied or uploaded, is still subject to the minimum part size. Note also that this method does not finish the large file.

        Specified by:
        storePartsForLargeFile in interface B2StorageClient
        Parameters:
        fileVersion - The B2FileVersion for the large file for which these parts are being uploaded. This is the return value of startLargeFile().
        partStorers - The list of objects that know how to store the part they are responsible for.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The list of parts after all have been stored.
        Throws:
        B2Exception - If there's trouble.
      • storePartsForLargeFile

        public java.util.List<B2Part> storePartsForLargeFile​(B2StoreLargeFileRequest storeLargeFileRequest,
                                                             java.util.List<B2PartStorer> partStorers,
                                                             B2UploadListener uploadListenerOrNull,
                                                             java.util.concurrent.ExecutorService executor)
                                                      throws B2Exception
        Description copied from interface: B2StorageClient
        Stores large file parts, where storing each part may involve different behavior or byte sources, optionally allowing caller to pass SSE-C parameters to match those given to startLargeFile().

        For example, this method supports the use case of making a copy of a file that mostly has not changed, and the user only wishes to upload the parts that have changed. In this case partStorers would be a mix of B2CopyingPartStorers and one or more B2UploadingPartStorers.

        Another use case would be reattempting some part uploads for an unfinished large file for which some parts have completed, and some haven't. In this case, partStorers would be a mix of B2AlreadyStoredPartStorer and B2UploadingPartStorers.

        This method assumes you have already called startLargeFile(). The return value of that call needs to be passed into this method as part of a B2StoreLargeFileRequest. Note that each part, whether copied or uploaded, is still subject to the minimum part size. Note also that this method does not finish the large file.

        Specified by:
        storePartsForLargeFile in interface B2StorageClient
        Parameters:
        storeLargeFileRequest - The B2StoreLargeFileRequest for the large file for which these parts are being stored. This is built from the return value of startLargeFile() and any other relevant parameters.
        partStorers - The list of objects that know how to store the part they are responsible for.
        uploadListenerOrNull - The object that handles upload progress events. This may be null if you do not need to be notified of progress events.
        executor - The executor for uploading parts in parallel. The caller retains ownership of the executor and is responsible for shutting it down.
        Returns:
        The list of parts after all have been stored.
        Throws:
        B2Exception - If there's trouble.
      • fileVersions

        public B2ListFilesIterable fileVersions​(B2ListFileVersionsRequest request)
                                         throws B2Exception
        Description copied from interface: B2StorageClient
        Returns an iterable whose iterator yields the fileVersions that match the given request. It will automatically call B2 to get batches of answers as needed. If there's any trouble during hasNext() or next(), it will throw a B2RuntimeException since Iterable<> doesn't allow checked exceptions to be thrown.
        Specified by:
        fileVersions in interface B2StorageClient
        Parameters:
        request - specifies which fileVersions to list.
        Returns:
        a new iterable to iterate over fileVersions that match the given request.
        Throws:
        B2Exception - if there's any trouble
      • fileNames

        public B2ListFilesIterable fileNames​(B2ListFileNamesRequest request)
                                      throws B2Exception
        Description copied from interface: B2StorageClient
        Returns an iterable whose iterator yields the fileNames that match the given request. It will automatically call B2 to get batches of answers as needed. If there's any trouble during hasNext() or next(), it will throw a B2RuntimeException since Iterable<> doesn't allow checked exceptions to be thrown.
        Specified by:
        fileNames in interface B2StorageClient
        Parameters:
        request - specifies which fileVersions to list.
        Returns:
        a new iterable to iterate over fileVersions that match the given request.
        Throws:
        B2Exception - if there's any trouble
      • unfinishedLargeFiles

        public B2ListFilesIterable unfinishedLargeFiles​(B2ListUnfinishedLargeFilesRequest request)
        Description copied from interface: B2StorageClient
        Returns an iterable whose iterator yields the fileVersions of large, unfinished files that match the given request. It will automatically call B2 to get batches of answers as needed. If there's any trouble during hasNext() or next(), it will throw a B2RuntimeException since Iterable<> doesn't allow checked exceptions to be thrown.
        Specified by:
        unfinishedLargeFiles in interface B2StorageClient
        Parameters:
        request - specifies which unfinished large files to list
        Returns:
        a new iterable to iterate over fileVersions that match the given request.
      • parts

        public B2ListPartsIterable parts​(B2ListPartsRequest request)
                                  throws B2Exception
        Description copied from interface: B2StorageClient
        Returns an iterable whose iterator yields the parts of large, unfinished files that match the given request. It will automatically call B2 to get batches of answers as needed. If there's any trouble during hasNext() or next(), it will throw a B2RuntimeException since Iterable<> doesn't allow checked exceptions to be thrown.
        Specified by:
        parts in interface B2StorageClient
        Parameters:
        request - specifies which parts to list
        Returns:
        a new iterable to iterate over parts that match the given request.
        Throws:
        B2Exception - if there's any trouble
      • downloadById

        public void downloadById​(B2DownloadByIdRequest request,
                                 B2ContentSink handler)
                          throws B2Exception
        Description copied from interface: B2StorageClient
        Asks to download the specified file by id.
        Specified by:
        downloadById in interface B2StorageClient
        Parameters:
        request - specifies the file and which part of the file to request.
        handler - if the server starts sending us the file, the headers and input stream are passed to the handler. NOTE: if you get an exception while processing the stream, be sure to clean up anything you've created. the handler may or may not be called again based on the exception.
        Throws:
        B2Exception - if there's trouble with the request or if the handler throws an exception.
      • getDownloadByIdUrl

        public java.lang.String getDownloadByIdUrl​(B2DownloadByIdRequest request)
                                            throws B2Exception
        Description copied from interface: B2StorageClient
        Returns the URL for downloading the file specified by the request. Note that note all of the request will be represented in the URL. For instance, the url will not contain authorization or range information since we normally send those in the request headers.

        This is useful for generating public URLs and as part of generating signed download URLs.

        Specified by:
        getDownloadByIdUrl in interface B2StorageClient
        Parameters:
        request - specifies what to download.
        Returns:
        a URL for fetching the file.
        Throws:
        B2Exception - if there's any trouble.
      • getDownloadByNameUrl

        public java.lang.String getDownloadByNameUrl​(B2DownloadByNameRequest request)
                                              throws B2Exception
        Description copied from interface: B2StorageClient
        Returns the URL for downloading the file specified by the request. Note that note all of the request will be represented in the URL. For instance, the url will not contain authorization or range information since we normally send those in the request headers.

        This is useful for generating public URLs and as part of generating signed download URLs.

        Specified by:
        getDownloadByNameUrl in interface B2StorageClient
        Parameters:
        request - specifies what to download.
        Returns:
        a URL for fetching the file.
        Throws:
        B2Exception - if there's any trouble.
      • downloadByName

        public void downloadByName​(B2DownloadByNameRequest request,
                                   B2ContentSink handler)
                            throws B2Exception
        Description copied from interface: B2StorageClient
        Asks to download the specified file by bucket name and file name.
        Specified by:
        downloadByName in interface B2StorageClient
        Parameters:
        request - specifies the file and which part of the file to request.
        handler - if the server starts sending us the file, the headers and input stream are passed to the handler. NOTE: if you get an exception while processing the stream, be sure to clean up anything you've created. the handler may or may not be called again based on the exception.
        Throws:
        B2Exception - if there's trouble with the request or if the handler throws an exception.
      • getAccountAuthorization

        public B2AccountAuthorization getAccountAuthorization()
                                                       throws B2Exception
        Description copied from interface: B2StorageClient
        This method provides access to an account authorization structure. The returned structure may have been cached. When possible, you should use other objects and helpers instead of using the account authorization directly, so that the B2StorageClient can properly invalidate the cached authorization, if any, in response to interactions with the server. For instance, for downloading: * to download files, use downloadByName() or downloadById(). * if you don't want to download directly, but need to give a download url to some other code, use getDownloadByIdUrl() or getDownloadByNameUrl(). * if neither of those will work for you because you need some other code to be able to form the download urls itself, you may need to getAccountAuthorization() and get the downloadUrl from it. For instance, when deciding whether to use uploadSmallFile() or uploadLargeFile(), call getFilePolicy() and use the helper methods on the result.
        Specified by:
        getAccountAuthorization in interface B2StorageClient
        Returns:
        the account authorization, possibly from a cache.
        Throws:
        B2Exception - if there's trouble getting the authorization.
      • invalidateAccountAuthorization

        public void invalidateAccountAuthorization()
        Description copied from interface: B2StorageClient
        If there's a cached account authorization, this will flush the cache so that the authorization will need to be reacquired the next time it is needed. (Keep in mind that another thread may need it and reacquire it before this method even returns.) You should never need to call this unless you have called getAccountAuthorization() and have gotten some kind of authorization exception when using the contents of that authorization. It's really a lot simpler for you if you never do that and instead always do your work through B2StorageClient's APIs!
        Specified by:
        invalidateAccountAuthorization in interface B2StorageClient
      • getUploadUrl

        public B2UploadUrlResponse getUploadUrl​(B2GetUploadUrlRequest request)
                                         throws B2Exception
        Description copied from interface: B2StorageClient
        This method allows the caller to get an upload url and authorization token directly. Note that the SDK has lots of logic to upload files and getting upload URLs and using them outside the SDK means that you need to handle lots of details of uploading by yourself including: * retrying based on the types of errors you get, with proper backoff. * refreshing your account authorization when it expires. * reusing upload urls when possible * etc. When possible you should seriously consider using uploadSmallFile() and uploadLargeFile() instead of reimplementing that logic. If there's a reason you can't use those methods, let us know. Perhaps we can improve things together to meet your needs.
        Specified by:
        getUploadUrl in interface B2StorageClient
        Parameters:
        request - specifies details about the desired upload url and credentials.
        Returns:
        the response from the server.
        Throws:
        B2Exception - if there's any trouble.
      • getUploadPartUrl

        public B2UploadPartUrlResponse getUploadPartUrl​(B2GetUploadPartUrlRequest request)
                                                 throws B2Exception
        Description copied from interface: B2StorageClient
        This method allows the caller to get an upload url and authorization token directly for uploading a large file part. Note that the SDK has lots of logic to upload files and getting upload URLs and using them outside the SDK means that you need to handle lots of details of uploading by yourself including: * retrying based on the types of errors you get, with proper backoff. * refreshing your account authorization when it expires. * reusing upload urls when possible * etc. When possible you should seriously consider using uploadSmallFile() and uploadLargeFile() instead of reimplementing that logic. If there's a reason you can't use those methods, let us know. Perhaps we can improve things together to meet your needs.
        Specified by:
        getUploadPartUrl in interface B2StorageClient
        Parameters:
        request - specifies details about the desired upload url and credentials.
        Returns:
        the response from the server.
        Throws:
        B2Exception - if there's any trouble.
      • startLargeFile

        public B2FileVersion startLargeFile​(B2StartLargeFileRequest request)
                                     throws B2Exception
        Description copied from interface: B2StorageClient
        This method allows the caller to start a large file. Note that the SDK has lots of logic to upload large files and doing your own uploading outside the SDK means that you need to handle lots of details of uploading by yourself including: * retrying based on the types of errors you get, with proper backoff. * refreshing your account authorization when it expires. * reusing upload urls when possible * etc. When possible you should seriously consider using uploadLargeFile() instead of reimplementing that logic. If there's a reason you can't use those methods, let us know. Perhaps we can improve things together to meet your needs.
        Specified by:
        startLargeFile in interface B2StorageClient
        Parameters:
        request - specifies details about the file to start.
        Returns:
        the response from the server.
        Throws:
        B2Exception - if there's any trouble.
      • finishLargeFile

        public B2FileVersion finishLargeFile​(B2FinishLargeFileRequest request)
                                      throws B2Exception
        Description copied from interface: B2StorageClient
        This method allows the caller to finish a large file. Note that the SDK has lots of logic to upload large files and doing your own uploading outside the SDK means that you need to handle lots of details of uploading by yourself including: * retrying based on the types of errors you get, with proper backoff. * refreshing your account authorization when it expires. * reusing upload urls when possible * etc. When possible you should seriously consider using uploadLargeFile() or finishUploadingLargeFile() instead of reimplementing that logic. If there's a reason you can't use those methods, let us know. Perhaps we can improve things together to meet your needs.
        Specified by:
        finishLargeFile in interface B2StorageClient
        Parameters:
        request - specifies details about the file to finish.
        Returns:
        the response from the server.
        Throws:
        B2Exception - if there's any trouble.