JCLOUDS-1394: Increase Azure max blob size to 256MB

This commit is contained in:
Alin Dreghiciu 2018-03-09 12:28:51 +02:00 committed by Andrew Gaul
parent 584ca19fad
commit 775921cd5d
3 changed files with 11 additions and 9 deletions

View File

@ -321,10 +321,10 @@ public interface AzureBlobClient extends Closeable {
* blob. * blob.
* <p/> * <p/>
* <h4>Remarks</h4> * <h4>Remarks</h4>
* The maximum upload size for a blob is 64 MB. If your blob is larger than 64 MB, you may upload * The maximum upload size for a blob is 256 MB. If your blob is larger than 256 MB, you may upload
* it as a set of blocks. For more information, see the Put Block and Put Block List operations. * it as a set of blocks. For more information, see the Put Block and Put Block List operations.
* <p/> * <p/>
* If you attempt to upload a blob that is larger than 64 MB, the service returns status code 413 * If you attempt to upload a blob that is larger than 256 MB, the service returns status code 413
* (Request Payload Too Large). The Blob service also returns additional information about the * (Request Payload Too Large). The Blob service also returns additional information about the
* error in the response, including the maximum blob size permitted in bytes. * error in the response, including the maximum blob size permitted in bytes.
*/ */

View File

@ -76,9 +76,11 @@ public class BindAzureBlobMetadataToRequest implements Binder {
headers.put("x-ms-blob-content-length", blob.getPayload().getContentMetadata().getContentLength().toString()); headers.put("x-ms-blob-content-length", blob.getPayload().getContentMetadata().getContentLength().toString());
break; break;
case BLOCK_BLOB: case BLOCK_BLOB:
// see https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-block-blobs--append-blobs--and-page-blobs
// see AzureBlobApiMetadata#version (current API version used is 2017-04-17)
checkArgument( checkArgument(
checkNotNull(blob.getPayload().getContentMetadata().getContentLength(), "blob.getContentLength()") <= 64L * 1024 * 1024, checkNotNull(blob.getPayload().getContentMetadata().getContentLength(), "blob.getContentLength()") <= 256L * 1024 * 1024,
"maximum size for put Blob is 64MB"); "maximum size for put Blob is 256MB");
break; break;
} }
request = (R) request.toBuilder().replaceHeaders(Multimaps.forMap(headers.build())).build(); request = (R) request.toBuilder().replaceHeaders(Multimaps.forMap(headers.build())).build();

View File

@ -35,10 +35,10 @@ import com.google.common.collect.ImmutableMap;
public class BindAzureBlobMetadataToRequestTest extends BaseRestAnnotationProcessingTest<AzureBlobClient> { public class BindAzureBlobMetadataToRequestTest extends BaseRestAnnotationProcessingTest<AzureBlobClient> {
@Test @Test
public void testPassWithMinimumDetailsAndPayload64MB() { public void testPassWithMinimumDetailsAndPayload256MB() {
AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null); AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null);
Payload payload = Payloads.newStringPayload(""); Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(64 * 1024 * 1024L); payload.getContentMetadata().setContentLength(256 * 1024 * 1024L);
blob.setPayload(payload); blob.setPayload(payload);
blob.getProperties().setName("foo"); blob.getProperties().setName("foo");
@ -55,7 +55,7 @@ public class BindAzureBlobMetadataToRequestTest extends BaseRestAnnotationProces
public void testExtendedPropertiesBind() { public void testExtendedPropertiesBind() {
AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null); AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null);
Payload payload = Payloads.newStringPayload(""); Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(64 * 1024 * 1024L); payload.getContentMetadata().setContentLength(256 * 1024 * 1024L);
blob.setPayload(payload); blob.setPayload(payload);
blob.getProperties().setName("foo"); blob.getProperties().setName("foo");
blob.getProperties().setMetadata(ImmutableMap.of("foo", "bar")); blob.getProperties().setMetadata(ImmutableMap.of("foo", "bar"));
@ -96,10 +96,10 @@ public class BindAzureBlobMetadataToRequestTest extends BaseRestAnnotationProces
} }
@Test(expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testOver64MBIsBad() { public void testOver256MBIsBad() {
AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null); AzureBlob blob = injector.getInstance(AzureBlob.Factory.class).create(null);
Payload payload = Payloads.newStringPayload(""); Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(64 * 1024 * 1024L + 1); payload.getContentMetadata().setContentLength(256 * 1024 * 1024L + 1);
blob.setPayload(payload); blob.setPayload(payload);
blob.getProperties().setName("foo"); blob.getProperties().setName("foo");