JCLOUDS-801: Use Iterable payload slicer for AWS-S3

Payload slicer has a method that returns an iterable of payloads that
works on non-repeatable InputStreams that was introduced to fix
multi-part uploads in Swift (JCLOUDS-356). This commit applies the
same method to fix multi-part uploads for AWS-S3 blob store.
This commit is contained in:
Andrew Gaul 2015-01-07 15:47:07 -08:00
parent 57a1f0e986
commit 38ebf0d06c
2 changed files with 15 additions and 13 deletions

View File

@ -65,6 +65,12 @@ public class BindObjectMetadataToRequest implements Binder {
if (md.getContentMetadata().getContentEncoding() != null) {
headers.put("Content-Encoding", md.getContentMetadata().getContentEncoding());
}
String contentLanguage = md.getContentMetadata().getContentLanguage();
if (contentLanguage != null) {
headers.put(HttpHeaders.CONTENT_LANGUAGE, contentLanguage);
}
if (md.getContentMetadata().getContentType() != null) {
headers.put(HttpHeaders.CONTENT_TYPE, md.getContentMetadata().getContentType());
} else {

View File

@ -81,19 +81,16 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
if (partCount > 0) {
ObjectMetadataBuilder builder = ObjectMetadataBuilder.create().key(key)
.contentType(metadata.getContentType())
.contentDisposition(metadata.getContentDisposition());
.contentDisposition(metadata.getContentDisposition())
.contentEncoding(metadata.getContentEncoding())
.contentLanguage(metadata.getContentLanguage())
.userMetadata(blob.getMetadata().getUserMetadata());
String uploadId = client.initiateMultipartUpload(container, builder.build());
try {
SortedMap<Integer, String> etags = Maps.newTreeMap();
int part;
while ((part = algorithm.getNextPart()) <= partCount) {
prepareUploadPart(container, key, uploadId, part, payload, algorithm.getNextChunkOffset(), chunkSize,
etags);
}
long remaining = algorithm.getRemaining();
if (remaining > 0) {
prepareUploadPart(container, key, uploadId, part, payload, algorithm.getNextChunkOffset(), remaining,
etags);
for (Payload part : slicer.slice(payload, chunkSize)) {
int partNum = algorithm.getNextPart();
prepareUploadPart(container, key, uploadId, partNum, part, algorithm.getNextChunkOffset(), etags);
}
return client.completeMultipartUpload(container, key, uploadId, etags);
} catch (RuntimeException ex) {
@ -107,9 +104,8 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
}
}
private void prepareUploadPart(String container, String key, String uploadId, int part, Payload payload,
long offset, long size, SortedMap<Integer, String> etags) {
Payload chunkedPart = slicer.slice(payload, offset, size);
private void prepareUploadPart(String container, String key, String uploadId, int part, Payload chunkedPart,
long offset, SortedMap<Integer, String> etags) {
String eTag = null;
try {
eTag = client.uploadPart(container, key, part, uploadId, chunkedPart);