|
38 | 38 | import com.backblaze.b2.client.structures.B2ListPartsRequest; |
39 | 39 | import com.backblaze.b2.client.structures.B2ListUnfinishedLargeFilesRequest; |
40 | 40 | import com.backblaze.b2.client.structures.B2StartLargeFileRequest; |
| 41 | +import com.backblaze.b2.client.structures.B2StoreLargeFileRequest; |
41 | 42 | import com.backblaze.b2.client.structures.B2UpdateBucketRequest; |
| 43 | +import com.backblaze.b2.client.structures.B2UpdateFileLegalHoldRequest; |
| 44 | +import com.backblaze.b2.client.structures.B2UpdateFileLegalHoldResponse; |
| 45 | +import com.backblaze.b2.client.structures.B2UpdateFileRetentionRequest; |
| 46 | +import com.backblaze.b2.client.structures.B2UpdateFileRetentionResponse; |
42 | 47 | import com.backblaze.b2.client.structures.B2UploadFileRequest; |
43 | 48 | import com.backblaze.b2.client.structures.B2UploadListener; |
44 | 49 | import com.backblaze.b2.client.structures.B2UploadPartUrlResponse; |
45 | 50 | import com.backblaze.b2.client.structures.B2UploadUrlResponse; |
| 51 | +import com.backblaze.b2.util.B2Preconditions; |
46 | 52 |
|
47 | 53 | import java.io.Closeable; |
48 | 54 | import java.util.List; |
@@ -265,6 +271,37 @@ B2FileVersion storeLargeFileFromLocalContent( |
265 | 271 | B2UploadListener uploadListenerOrNull, |
266 | 272 | ExecutorService executor) throws B2Exception; |
267 | 273 |
|
| 274 | + /** |
| 275 | + * Uploads the specified content source as separate parts to form a B2 large file, |
| 276 | + * optionally allowing caller to pass SSE-C parameters to match those given to |
| 277 | + * startLargeFile(). |
| 278 | + * |
| 279 | + * This method assumes you have already called startLargeFile(). The return value |
| 280 | + * of that call needs to be passed into this method as part of a |
| 281 | + * B2StoreLargeFileRequest. However, this method will currently call finish file. |
| 282 | + * |
| 283 | + * XXX: should we switch to letting the caller finish the large file? |
| 284 | + * |
| 285 | + * @param storeLargeFileRequest The B2StoreLargeFileRequest for the large file |
| 286 | + * getting stored. This is built from the return |
| 287 | + * value of startLargeFile() and any other relevant |
| 288 | + * parameters. |
| 289 | + * @param contentSource The contentSource to upload. |
| 290 | + * @param uploadListenerOrNull The object that handles upload progress events. |
| 291 | + * This may be null if you do not need to be notified |
| 292 | + * of progress events. |
| 293 | + * @param executor The executor for uploading parts in parallel. The caller |
| 294 | + * retains ownership of the executor and is responsible for |
| 295 | + * shutting it down. |
| 296 | + * @return The fileVersion of the large file after it has been finished. |
| 297 | + * @throws B2Exception If there's trouble. |
| 298 | + */ |
| 299 | + B2FileVersion storeLargeFileFromLocalContent( |
| 300 | + B2StoreLargeFileRequest storeLargeFileRequest, |
| 301 | + B2ContentSource contentSource, |
| 302 | + B2UploadListener uploadListenerOrNull, |
| 303 | + ExecutorService executor) throws B2Exception; |
| 304 | + |
268 | 305 | /** |
269 | 306 | * Initiates uploading the specified content source as separate parts to form a |
270 | 307 | * B2 large file. This allows the upload to be cancelled partway through. |
@@ -298,6 +335,41 @@ CompletableFuture<B2FileVersion> storeLargeFileFromLocalContentAsync( |
298 | 335 | B2UploadListener uploadListenerOrNull, |
299 | 336 | ExecutorService executor) throws B2Exception; |
300 | 337 |
|
| 338 | + /** |
| 339 | + * Initiates uploading the specified content source as separate parts to form a |
| 340 | + * B2 large file. This allows the upload to be cancelled partway through. |
| 341 | + * |
| 342 | + * This method assumes you have already called startLargeFile(). The return value |
| 343 | + * of that call needs to be passed into this method. |
| 344 | + * |
| 345 | + * The returned future can be cancelled and this will also attempt to stop any part |
| 346 | + * uploads in progress. |
| 347 | + * |
| 348 | + * Cancelling after the b2_finish_large_file API call has been started will result in the |
| 349 | + * future being cancelled, but the API call can still succeed. There is no way to tell from |
| 350 | + * the future whether this is the case. The caller is responsible for checking and calling |
| 351 | + * B2StorageClient.cancelLargeFile. |
| 352 | + * |
| 353 | + * @param storeLargeFileRequest The B2StoreLargeFileRequest for the large file |
| 354 | + * getting stored. This is built from the return |
| 355 | + * value of startLargeFile() and any other relevant |
| 356 | + * parameters. |
| 357 | + * @param contentSource The contentSource to upload. |
| 358 | + * @param uploadListenerOrNull The object that handles upload progress events. |
| 359 | + * This may be null if you do not need to be notified |
| 360 | + * of progress events. |
| 361 | + * @param executor The executor for uploading parts in parallel. The caller |
| 362 | + * retains ownership of the executor and is responsible for |
| 363 | + * shutting it down. |
| 364 | + * @return CompletableFuture with the resulting B2FileVersion of the completed file |
| 365 | + * @throws B2Exception on error |
| 366 | + */ |
| 367 | + CompletableFuture<B2FileVersion> storeLargeFileFromLocalContentAsync( |
| 368 | + B2StoreLargeFileRequest storeLargeFileRequest, |
| 369 | + B2ContentSource contentSource, |
| 370 | + B2UploadListener uploadListenerOrNull, |
| 371 | + ExecutorService executor) throws B2Exception; |
| 372 | + |
301 | 373 | /** |
302 | 374 | * Stores a large file, where storing each part may involve different behavior |
303 | 375 | * or byte sources. |
@@ -337,6 +409,47 @@ B2FileVersion storeLargeFile( |
337 | 409 | B2UploadListener uploadListenerOrNull, |
338 | 410 | ExecutorService executor) throws B2Exception; |
339 | 411 |
|
| 412 | + /** |
| 413 | + * Stores a large file, where storing each part may involve different behavior |
| 414 | + * or byte sources, optionally allowing caller to pass SSE-C parameters to match |
| 415 | + * those given to startLargeFile(). |
| 416 | + * |
| 417 | + * For example, this method supports the use case of making a copy of a file |
| 418 | + * that mostly has not changed, and the user only wishes to upload the parts |
| 419 | + * that have changed. In this case partStorers would be a mix of |
| 420 | + * B2CopyingPartStorers and one or more B2UploadingPartStorers. |
| 421 | + * |
| 422 | + * Another use case would be reattempting an upload of a large file where some |
| 423 | + * parts have completed, and some haven't. In this case, partStorers would |
| 424 | + * be a mix of B2AlreadyStoredPartStorer and B2UploadingPartStorers. |
| 425 | + * |
| 426 | + * This method assumes you have already called startLargeFile(). The return value |
| 427 | + * of that call needs to be passed into this method as part of a |
| 428 | + * B2StoreLargeFileRequest. However, this method will currently call finish file. |
| 429 | + * Note that each part, whether copied or uploaded, |
| 430 | + * is still subject to the minimum part size. |
| 431 | + * |
| 432 | + * @param storeLargeFileRequest The B2StoreLargeFileRequest for the large file |
| 433 | + * getting stored. This is built from the return |
| 434 | + * value of startLargeFile() and any other relevant |
| 435 | + * parameters. |
| 436 | + * @param partStorers The list of objects that know how to store the part |
| 437 | + * they are responsible for. |
| 438 | + * @param uploadListenerOrNull The object that handles upload progress events. |
| 439 | + * This may be null if you do not need to be notified |
| 440 | + * of progress events. |
| 441 | + * @param executor The executor for uploading parts in parallel. The caller |
| 442 | + * retains ownership of the executor and is responsible for |
| 443 | + * shutting it down. |
| 444 | + * @return The fileVersion of the large file after it has been finished. |
| 445 | + * @throws B2Exception If there's trouble. |
| 446 | + */ |
| 447 | + B2FileVersion storeLargeFile( |
| 448 | + B2StoreLargeFileRequest storeLargeFileRequest, |
| 449 | + List<B2PartStorer> partStorers, |
| 450 | + B2UploadListener uploadListenerOrNull, |
| 451 | + ExecutorService executor) throws B2Exception; |
| 452 | + |
340 | 453 | /** |
341 | 454 | * Verifies that the given fileVersion represents an unfinished large file |
342 | 455 | * and that the specified content is compatible-enough with the information |
@@ -877,6 +990,25 @@ default String getDownloadByNameUrl(String bucketName, |
877 | 990 | */ |
878 | 991 | B2FileVersion finishLargeFile(B2FinishLargeFileRequest request) throws B2Exception; |
879 | 992 |
|
| 993 | + /** |
| 994 | + * Updates the legal hold configuration of the specified file as described by the request. |
| 995 | + * |
| 996 | + * @param request specifies which file to update and how to update it. |
| 997 | + * @return the new state of the file |
| 998 | + * @throws B2Exception if there's any trouble. |
| 999 | + * @see <a href="https://www.backblaze.com/b2/docs/b2_update_file_legal_hold.html">b2_update_file_legal_hold</a> |
| 1000 | + */ |
| 1001 | + B2UpdateFileLegalHoldResponse updateFileLegalHold(B2UpdateFileLegalHoldRequest request) throws B2Exception; |
| 1002 | + |
| 1003 | + /** |
| 1004 | + * Updates the file retention configuration of the specified file as described by the request. |
| 1005 | + * |
| 1006 | + * @param request specifies which file to update and how to update it. |
| 1007 | + * @return the new state of the file |
| 1008 | + * @throws B2Exception if there's any trouble. |
| 1009 | + * @see <a href="https://www.backblaze.com/b2/docs/b2_update_file_retention.html">b2_update_file_retention</a> |
| 1010 | + */ |
| 1011 | + B2UpdateFileRetentionResponse updateFileRetention(B2UpdateFileRetentionRequest request) throws B2Exception; |
880 | 1012 |
|
881 | 1013 | /** |
882 | 1014 | * Closes this instance, releasing resources. |
|
0 commit comments