|
25 | 25 | import com.box.sdkgen.schemas.uploadpart.UploadPart; |
26 | 26 | import com.box.sdkgen.schemas.uploadparts.UploadParts; |
27 | 27 | import com.box.sdkgen.schemas.uploadsession.UploadSession; |
| 28 | +import com.box.sdkgen.schemas.uploadsessionplanrequest.UploadSessionPlanRequest; |
| 29 | +import com.box.sdkgen.schemas.uploadsessionplanresponse.UploadSessionPlanResponse; |
28 | 30 | import com.box.sdkgen.serialization.json.JsonManager; |
29 | 31 | import java.io.InputStream; |
30 | 32 | import java.util.Arrays; |
@@ -586,6 +588,121 @@ public UploadParts getFileUploadSessionParts( |
586 | 588 | return JsonManager.deserialize(response.getData(), UploadParts.class); |
587 | 589 | } |
588 | 590 |
|
| 591 | + /** |
| 592 | + * Using this method with urls provided in response when creating a new upload session is |
| 593 | + * preferred to use over CreateFileUploadSessionPlan method. This allows to always upload your |
| 594 | + * content to the closest Box data center and can significantly improve upload speed. Plan an |
| 595 | + * upload session by checking which parts already exist on the server. This endpoint allows |
| 596 | + * clients to optimize uploads by skipping parts that have already been uploaded (cache hits) and |
| 597 | + * only uploading missing parts. |
| 598 | + * |
| 599 | + * <p>The actual endpoint URL is returned by the [`Create upload |
| 600 | + * session`](e://post-files-upload-sessions) and [`Get upload |
| 601 | + * session`](e://get-files-upload-sessions-id) endpoints. |
| 602 | + * |
| 603 | + * @param url URL of createFileUploadSessionPlan method |
| 604 | + * @param requestBody Request body of createFileUploadSessionPlan method |
| 605 | + */ |
| 606 | + public UploadSessionPlanResponse createFileUploadSessionPlanByUrl( |
| 607 | + String url, UploadSessionPlanRequest requestBody) { |
| 608 | + return createFileUploadSessionPlanByUrl( |
| 609 | + url, requestBody, new CreateFileUploadSessionPlanByUrlHeaders()); |
| 610 | + } |
| 611 | + |
| 612 | + /** |
| 613 | + * Using this method with urls provided in response when creating a new upload session is |
| 614 | + * preferred to use over CreateFileUploadSessionPlan method. This allows to always upload your |
| 615 | + * content to the closest Box data center and can significantly improve upload speed. Plan an |
| 616 | + * upload session by checking which parts already exist on the server. This endpoint allows |
| 617 | + * clients to optimize uploads by skipping parts that have already been uploaded (cache hits) and |
| 618 | + * only uploading missing parts. |
| 619 | + * |
| 620 | + * <p>The actual endpoint URL is returned by the [`Create upload |
| 621 | + * session`](e://post-files-upload-sessions) and [`Get upload |
| 622 | + * session`](e://get-files-upload-sessions-id) endpoints. |
| 623 | + * |
| 624 | + * @param url URL of createFileUploadSessionPlan method |
| 625 | + * @param requestBody Request body of createFileUploadSessionPlan method |
| 626 | + * @param headers Headers of createFileUploadSessionPlan method |
| 627 | + */ |
| 628 | + public UploadSessionPlanResponse createFileUploadSessionPlanByUrl( |
| 629 | + String url, |
| 630 | + UploadSessionPlanRequest requestBody, |
| 631 | + CreateFileUploadSessionPlanByUrlHeaders headers) { |
| 632 | + Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); |
| 633 | + FetchResponse response = |
| 634 | + this.networkSession |
| 635 | + .getNetworkClient() |
| 636 | + .fetch( |
| 637 | + new FetchOptions.Builder(url, "POST") |
| 638 | + .headers(headersMap) |
| 639 | + .data(JsonManager.serialize(requestBody)) |
| 640 | + .contentType("application/json") |
| 641 | + .responseFormat(ResponseFormat.JSON) |
| 642 | + .auth(this.auth) |
| 643 | + .networkSession(this.networkSession) |
| 644 | + .build()); |
| 645 | + return JsonManager.deserialize(response.getData(), UploadSessionPlanResponse.class); |
| 646 | + } |
| 647 | + |
| 648 | + /** |
| 649 | + * Plan an upload session by checking which parts already exist on the server. This endpoint |
| 650 | + * allows clients to optimize uploads by skipping parts that have already been uploaded (cache |
| 651 | + * hits) and only uploading missing parts. |
| 652 | + * |
| 653 | + * <p>The actual endpoint URL is returned by the [`Create upload |
| 654 | + * session`](e://post-files-upload-sessions) and [`Get upload |
| 655 | + * session`](e://get-files-upload-sessions-id) endpoints. |
| 656 | + * |
| 657 | + * @param uploadSessionId The ID of the upload session. Example: "D5E3F7A" |
| 658 | + * @param requestBody Request body of createFileUploadSessionPlan method |
| 659 | + */ |
| 660 | + public UploadSessionPlanResponse createFileUploadSessionPlan( |
| 661 | + String uploadSessionId, UploadSessionPlanRequest requestBody) { |
| 662 | + return createFileUploadSessionPlan( |
| 663 | + uploadSessionId, requestBody, new CreateFileUploadSessionPlanHeaders()); |
| 664 | + } |
| 665 | + |
| 666 | + /** |
| 667 | + * Plan an upload session by checking which parts already exist on the server. This endpoint |
| 668 | + * allows clients to optimize uploads by skipping parts that have already been uploaded (cache |
| 669 | + * hits) and only uploading missing parts. |
| 670 | + * |
| 671 | + * <p>The actual endpoint URL is returned by the [`Create upload |
| 672 | + * session`](e://post-files-upload-sessions) and [`Get upload |
| 673 | + * session`](e://get-files-upload-sessions-id) endpoints. |
| 674 | + * |
| 675 | + * @param uploadSessionId The ID of the upload session. Example: "D5E3F7A" |
| 676 | + * @param requestBody Request body of createFileUploadSessionPlan method |
| 677 | + * @param headers Headers of createFileUploadSessionPlan method |
| 678 | + */ |
| 679 | + public UploadSessionPlanResponse createFileUploadSessionPlan( |
| 680 | + String uploadSessionId, |
| 681 | + UploadSessionPlanRequest requestBody, |
| 682 | + CreateFileUploadSessionPlanHeaders headers) { |
| 683 | + Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders())); |
| 684 | + FetchResponse response = |
| 685 | + this.networkSession |
| 686 | + .getNetworkClient() |
| 687 | + .fetch( |
| 688 | + new FetchOptions.Builder( |
| 689 | + String.join( |
| 690 | + "", |
| 691 | + this.networkSession.getBaseUrls().getUploadUrl(), |
| 692 | + "/2.0/files/upload_sessions/", |
| 693 | + convertToString(uploadSessionId), |
| 694 | + "/plan"), |
| 695 | + "POST") |
| 696 | + .headers(headersMap) |
| 697 | + .data(JsonManager.serialize(requestBody)) |
| 698 | + .contentType("application/json") |
| 699 | + .responseFormat(ResponseFormat.JSON) |
| 700 | + .auth(this.auth) |
| 701 | + .networkSession(this.networkSession) |
| 702 | + .build()); |
| 703 | + return JsonManager.deserialize(response.getData(), UploadSessionPlanResponse.class); |
| 704 | + } |
| 705 | + |
589 | 706 | /** |
590 | 707 | * Using this method with urls provided in response when creating a new upload session is |
591 | 708 | * preferred to use over CreateFileUploadSessionCommit method. This allows to always upload your |
|
0 commit comments