11package synapticloop .b2 ;
22
3+ import java .io .File ;
4+ import java .io .IOException ;
5+ import java .io .InputStream ;
6+ import java .util .List ;
7+ import java .util .Map ;
8+
39/*
410 * Copyright (c) 2016 Synapticloop.
511 *
2026import org .apache .http .HttpEntity ;
2127import org .apache .http .impl .client .CloseableHttpClient ;
2228import org .apache .http .impl .client .HttpClients ;
29+
2330import synapticloop .b2 .exception .B2ApiException ;
24- import synapticloop .b2 .request .*;
25- import synapticloop .b2 .response .*;
31+ import synapticloop .b2 .request .B2AuthorizeAccountRequest ;
32+ import synapticloop .b2 .request .B2CancelLargeFileRequest ;
33+ import synapticloop .b2 .request .B2CreateBucketRequest ;
34+ import synapticloop .b2 .request .B2DeleteBucketRequest ;
35+ import synapticloop .b2 .request .B2DeleteFileVersionRequest ;
36+ import synapticloop .b2 .request .B2DownloadFileByIdRequest ;
37+ import synapticloop .b2 .request .B2DownloadFileByNameRequest ;
38+ import synapticloop .b2 .request .B2FinishLargeFileRequest ;
39+ import synapticloop .b2 .request .B2GetFileInfoRequest ;
40+ import synapticloop .b2 .request .B2GetUploadPartUrlRequest ;
41+ import synapticloop .b2 .request .B2GetUploadUrlRequest ;
42+ import synapticloop .b2 .request .B2HeadFileByIdRequest ;
43+ import synapticloop .b2 .request .B2HideFileRequest ;
44+ import synapticloop .b2 .request .B2ListBucketsRequest ;
45+ import synapticloop .b2 .request .B2ListFileNamesRequest ;
46+ import synapticloop .b2 .request .B2ListFileVersionsRequest ;
47+ import synapticloop .b2 .request .B2ListPartsRequest ;
48+ import synapticloop .b2 .request .B2ListUnfinishedLargeFilesRequest ;
49+ import synapticloop .b2 .request .B2StartLargeFileRequest ;
50+ import synapticloop .b2 .request .B2UpdateBucketRequest ;
51+ import synapticloop .b2 .request .B2UploadFileRequest ;
52+ import synapticloop .b2 .request .B2UploadPartRequest ;
53+ import synapticloop .b2 .response .B2AuthorizeAccountResponse ;
54+ import synapticloop .b2 .response .B2BucketResponse ;
55+ import synapticloop .b2 .response .B2DeleteFileVersionResponse ;
56+ import synapticloop .b2 .response .B2DownloadFileResponse ;
57+ import synapticloop .b2 .response .B2FileResponse ;
58+ import synapticloop .b2 .response .B2FinishLargeFileResponse ;
59+ import synapticloop .b2 .response .B2GetUploadPartUrlResponse ;
60+ import synapticloop .b2 .response .B2GetUploadUrlResponse ;
61+ import synapticloop .b2 .response .B2HideFileResponse ;
62+ import synapticloop .b2 .response .B2ListFilesResponse ;
63+ import synapticloop .b2 .response .B2ListPartsResponse ;
64+ import synapticloop .b2 .response .B2StartLargeFileResponse ;
65+ import synapticloop .b2 .response .B2UploadPartResponse ;
2666import synapticloop .b2 .util .ChecksumHelper ;
2767
28- import java .io .File ;
29- import java .io .IOException ;
30- import java .io .InputStream ;
31- import java .util .List ;
32- import java .util .Map ;
33-
3468/**
3569 * This is a wrapper class for the underlying calls to the request/response
3670 * classes.
@@ -359,8 +393,11 @@ public B2FileResponse uploadFile(String bucketId, String fileName, File file) th
359393 * see <a href="https://www.backblaze.com/b2/docs/content-types.html">https://www.backblaze.com/b2/docs/content-types.html</a>
360394 * for a list of content type mappings.
361395 * @param fileInfo the file info map which will be set as 'X-Bz-Info-' headers
396+ *
362397 * @return The unique identifier for the file
398+ *
363399 * @throws B2ApiException if there was an error uploading the file
400+ * @throws IOException if there was an error with the underlying transport
364401 */
365402 public B2StartLargeFileResponse startLargeFileUpload (String bucketId , String fileName , String mimeType , Map <String , String > fileInfo ) throws B2ApiException , IOException {
366403 return new B2StartLargeFileRequest (client , b2AuthorizeAccountResponse , bucketId , fileName , mimeType , fileInfo ).getResponse ();
@@ -370,8 +407,11 @@ public B2StartLargeFileResponse startLargeFileUpload(String bucketId, String fil
370407 * Cancel large file upload
371408 *
372409 * @param fileId The ID returned by b2_start_large_file.
410+ *
373411 * @return File response
412+ *
374413 * @throws B2ApiException if there was an error canceling the upload
414+ * @throws IOException if there was an error with the underlying transport
375415 */
376416 public B2FileResponse cancelLargeFileUpload (String fileId ) throws B2ApiException , IOException {
377417 return new B2CancelLargeFileRequest (client , b2AuthorizeAccountResponse , fileId ).getResponse ();
@@ -381,8 +421,12 @@ public B2FileResponse cancelLargeFileUpload(String fileId) throws B2ApiException
381421 * Finish large file upload. Converts the parts that have been uploaded into a single B2 file.
382422 *
383423 * @param fileId The ID returned by b2_start_large_file.
424+ * @param partSha1Array the array of sha1 sums for each of the parts in order
425+ *
384426 * @return File response
427+ *
385428 * @throws B2ApiException if there was an error finishing the upload
429+ * @throws IOException if there was an error communicating with the API service
386430 */
387431 public B2FinishLargeFileResponse finishLargeFileUpload (String fileId , String [] partSha1Array ) throws B2ApiException , IOException {
388432 return new B2FinishLargeFileRequest (client , b2AuthorizeAccountResponse , fileId , partSha1Array ).getResponse ();
@@ -395,20 +439,27 @@ public B2FinishLargeFileResponse finishLargeFileUpload(String fileId, String[] p
395439 * @param partNumber A number from 1 to 10000. The parts uploaded for one file must have contiguous numbers, starting with 1.
396440 * @param entity Part content body
397441 * @param sha1Checksum the checksum for the part
442+ *
398443 * @return Upload response
444+ *
399445 * @throws B2ApiException if there was an error uploading the file
446+ * @throws IOException if there was an error communicating with the API service
400447 */
401448 public B2UploadPartResponse uploadLargeFilePart (String fileId , int partNumber , HttpEntity entity , String sha1Checksum ) throws B2ApiException , IOException {
402449 final B2GetUploadPartUrlResponse b2GetUploadUrlResponse = new B2GetUploadPartUrlRequest (client , b2AuthorizeAccountResponse , fileId ).getResponse ();
403450 return new B2UploadPartRequest (client , b2AuthorizeAccountResponse , b2GetUploadUrlResponse , partNumber , entity , sha1Checksum ).getResponse ();
404451 }
405452
406453 /**
407- * Lists information about large file uploads that have been started, but have not been finished or canceled .
454+ * Lists information about large file uploads that have been started, but have not been finished or cancelled .
408455 * Uploads are listed in the order they were started, with the oldest one first
409456 *
410457 * @param bucketId the id of the bucket
458+ * @param startFileId the start fileId to list from
459+ * @param maxFileCount the maximum number of files to return
460+ *
411461 * @return An array of objects, each one describing one unfinished file
462+ *
412463 * @throws B2ApiException if there was an error listing the files
413464 * @throws IOException if there was an error communicating with the API service
414465 */
@@ -420,7 +471,9 @@ public B2ListFilesResponse listUnfinishedLargeFiles(String bucketId, String star
420471 * @param fileId The ID returned by b2_start_large_file. This is the file whose parts will be listed.
421472 * @param startPartNumber Null to start
422473 * @param maxPartCount The maximum number of parts to return
474+ *
423475 * @return This call returns at most 1000 entries, but it can be called repeatedly to scan through all of the parts for an upload.
476+ *
424477 * @throws B2ApiException if there was an error listing the parts
425478 * @throws IOException if there was an error communicating with the API service
426479 */
0 commit comments