Skip to content

Commit

Permalink
Do not accept multipart sizes less than 5 MB
Browse files Browse the repository at this point in the history
Continue to enforce greater minimum blob sizes when storage backend
requires it.  Fixes #324.
  • Loading branch information
gaul committed Jun 24, 2020
1 parent 1e9c660 commit 34b844f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/gaul/s3proxy/S3ProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2257,8 +2257,9 @@ blobName, uploadId, new MutableBlobMetadataImpl(),
throw new S3Exception(S3ErrorCode.INVALID_PART);
}
long partSize = part.partSize();
if (partSize < blobStore.getMinimumMultipartPartSize() &&
partSize != -1 && it.hasNext()) {
if (it.hasNext() && partSize != -1 &&
(partSize < 5 * 1024 * 1024 || partSize <
blobStore.getMinimumMultipartPartSize())) {
throw new S3Exception(S3ErrorCode.ENTITY_TOO_SMALL);
}
if (part.partETag() != null &&
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/org/gaul/s3proxy/AwsSdkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public final class AwsSdkTest {
private static final ByteSource BYTE_SOURCE = ByteSource.wrap(new byte[1]);
private static final ClientConfiguration V2_SIGNER_CONFIG =
new ClientConfiguration().withSignerOverride("S3SignerType");
private static final long MINIMUM_MULTIPART_SIZE = 5 * 1024 * 1024;

private URI s3Endpoint;
private EndpointConfiguration s3EndpointConfig;
Expand Down Expand Up @@ -471,7 +472,7 @@ public void testMultipartCopy() throws Exception {
@Test
public void testBigMultipartUpload() throws Exception {
String key = "multipart-upload";
long partSize = context.getBlobStore().getMinimumMultipartPartSize();
long partSize = MINIMUM_MULTIPART_SIZE;
long size = partSize + 1;
ByteSource byteSource = TestUtils.randomByteSource().slice(0, size);

Expand Down Expand Up @@ -1094,11 +1095,9 @@ public void testMultipartUpload() throws Exception {
metadata));

ByteSource byteSource = TestUtils.randomByteSource().slice(
0, context.getBlobStore().getMinimumMultipartPartSize() + 1);
ByteSource byteSource1 = byteSource.slice(
0, context.getBlobStore().getMinimumMultipartPartSize());
ByteSource byteSource2 = byteSource.slice(
context.getBlobStore().getMinimumMultipartPartSize(), 1);
0, MINIMUM_MULTIPART_SIZE + 1);
ByteSource byteSource1 = byteSource.slice(0, MINIMUM_MULTIPART_SIZE);
ByteSource byteSource2 = byteSource.slice(MINIMUM_MULTIPART_SIZE, 1);
UploadPartResult part1 = client.uploadPart(new UploadPartRequest()
.withBucketName(containerName)
.withKey(blobName)
Expand Down Expand Up @@ -1195,7 +1194,7 @@ public void testMaximumMultipartUpload() throws Exception {
public void testMultipartUploadAbort() throws Exception {
String blobName = "multipart-upload-abort";
ByteSource byteSource = TestUtils.randomByteSource().slice(
0, context.getBlobStore().getMinimumMultipartPartSize());
0, MINIMUM_MULTIPART_SIZE);

InitiateMultipartUploadResult result = client.initiateMultipartUpload(
new InitiateMultipartUploadRequest(containerName, blobName));
Expand Down

0 comments on commit 34b844f

Please sign in to comment.