From 7a515eb9fd82cd9872a970dc7934ed60902aa1ba Mon Sep 17 00:00:00 2001 From: Daniil Trishkin Date: Wed, 15 Feb 2023 17:36:30 +0100 Subject: [PATCH] Fix multipart upload issues --- .../arc/storage/cloud/AzureBlobUploader.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dcm4chee-arc-storage-cloud/src/main/java/org/dcm4chee/arc/storage/cloud/AzureBlobUploader.java b/dcm4chee-arc-storage-cloud/src/main/java/org/dcm4chee/arc/storage/cloud/AzureBlobUploader.java index 5b7cc3445..1fb8c02b9 100644 --- a/dcm4chee-arc-storage-cloud/src/main/java/org/dcm4chee/arc/storage/cloud/AzureBlobUploader.java +++ b/dcm4chee-arc-storage-cloud/src/main/java/org/dcm4chee/arc/storage/cloud/AzureBlobUploader.java @@ -46,7 +46,6 @@ import java.util.List; import org.dcm4chee.arc.storage.CacheInputStream; -import org.jclouds.azureblob.blobstore.AzureBlobStore; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.domain.Blob; @@ -54,6 +53,7 @@ import org.jclouds.blobstore.domain.MultipartUpload; import org.jclouds.io.Payload; import org.jclouds.io.payloads.InputStreamPayload; +import org.jclouds.blobstore.options.PutOptions; /** * @author Daniil Trishkin @@ -82,18 +82,17 @@ private Payload createPayload() { private void uploadMultipleParts(BlobStoreContext context, InputStream in, String container, String storagePath) throws IOException { - AzureBlobStore blobStore = (AzureBlobStore) context.getBlobStore(); - Payload payload = createPayload(); - Blob blob = blobStore.blobBuilder(storagePath).payload(payload).build(); - MultipartUpload mpu = blobStore.initiateMultipartUpload(container, blob.getMetadata(), null); + BlobStore blobStore = context.getBlobStore(); + Blob blob = blobStore.blobBuilder(storagePath).payload(createPayload()).build(); + MultipartUpload mpu = blobStore.initiateMultipartUpload(container, blob.getMetadata(), new PutOptions().multipart()); List parts = new ArrayList(); int partNumber = 1; do { - parts.add(blobStore.uploadMultipartPart(mpu, partNumber, payload)); + parts.add(blobStore.uploadMultipartPart(mpu, partNumber, createPayload())); partNumber++; } while (fillBuffers(in)); if (available() > 0) - parts.add(blobStore.uploadMultipartPart(mpu, partNumber, payload)); + parts.add(blobStore.uploadMultipartPart(mpu, partNumber, createPayload())); blobStore.completeMultipartUpload(mpu, parts); } }