kopia lustrzana https://github.com/gaul/s3proxy
Provide content length to AmazonS3.putObject
Prevents warnings of the form: WARNING: No content length specified for stream data. Stream contents will be buffered in memory and could result in out of memory errors.pull/106/merge
rodzic
177d9b7566
commit
9af1d14dcc
|
@ -131,18 +131,22 @@ public final class S3AwsSdkTest {
|
||||||
AmazonS3 client = new AmazonS3Client(awsCreds,
|
AmazonS3 client = new AmazonS3Client(awsCreds,
|
||||||
new ClientConfiguration().withSignerOverride("S3SignerType"));
|
new ClientConfiguration().withSignerOverride("S3SignerType"));
|
||||||
client.setEndpoint(s3Endpoint.toString());
|
client.setEndpoint(s3Endpoint.toString());
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.setContentLength(BYTE_SOURCE.size());
|
||||||
client.putObject(containerName, "foo", BYTE_SOURCE.openStream(),
|
client.putObject(containerName, "foo", BYTE_SOURCE.openStream(),
|
||||||
new ObjectMetadata());
|
metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAwsV4Signature() throws Exception {
|
public void testAwsV4Signature() throws Exception {
|
||||||
final AmazonS3 client = new AmazonS3Client(awsCreds);
|
AmazonS3 client = new AmazonS3Client(awsCreds);
|
||||||
client.setEndpoint(s3Endpoint.toString());
|
client.setEndpoint(s3Endpoint.toString());
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.setContentLength(BYTE_SOURCE.size());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.putObject(containerName, "foo",
|
client.putObject(containerName, "foo",
|
||||||
BYTE_SOURCE.openStream(), new ObjectMetadata());
|
BYTE_SOURCE.openStream(), metadata);
|
||||||
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
|
Fail.failBecauseExceptionWasNotThrown(AmazonS3Exception.class);
|
||||||
} catch (AmazonS3Exception e) {
|
} catch (AmazonS3Exception e) {
|
||||||
assertThat(e.getErrorCode()).isEqualTo("InvalidArgument");
|
assertThat(e.getErrorCode()).isEqualTo("InvalidArgument");
|
||||||
|
@ -159,8 +163,10 @@ public final class S3AwsSdkTest {
|
||||||
client.setEndpoint(s3Endpoint.toString());
|
client.setEndpoint(s3Endpoint.toString());
|
||||||
|
|
||||||
String blobName = "foo";
|
String blobName = "foo";
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.setContentLength(BYTE_SOURCE.size());
|
||||||
client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
|
client.putObject(containerName, blobName, BYTE_SOURCE.openStream(),
|
||||||
new ObjectMetadata());
|
metadata);
|
||||||
|
|
||||||
Date expiration = new Date(System.currentTimeMillis() +
|
Date expiration = new Date(System.currentTimeMillis() +
|
||||||
TimeUnit.HOURS.toMillis(1));
|
TimeUnit.HOURS.toMillis(1));
|
||||||
|
@ -186,8 +192,10 @@ public final class S3AwsSdkTest {
|
||||||
String sourceBlobName = "testMultipartCopy-source";
|
String sourceBlobName = "testMultipartCopy-source";
|
||||||
String targetBlobName = "testMultipartCopy-target";
|
String targetBlobName = "testMultipartCopy-target";
|
||||||
|
|
||||||
|
ObjectMetadata metadata = new ObjectMetadata();
|
||||||
|
metadata.setContentLength(BYTE_SOURCE.size());
|
||||||
client.putObject(containerName, sourceBlobName,
|
client.putObject(containerName, sourceBlobName,
|
||||||
BYTE_SOURCE.openStream(), new ObjectMetadata());
|
BYTE_SOURCE.openStream(), metadata);
|
||||||
|
|
||||||
InitiateMultipartUploadRequest initiateRequest =
|
InitiateMultipartUploadRequest initiateRequest =
|
||||||
new InitiateMultipartUploadRequest(containerName,
|
new InitiateMultipartUploadRequest(containerName,
|
||||||
|
|
Ładowanie…
Reference in New Issue