checkNotNull(length,
"please invoke payload.getContentMetadata().setContentLength(length) prior to multipart upload");
long chunkSize = algorithm.calculateChunkSize(length);
int partCount = algorithm.getParts();
if (partCount > 0) {
ObjectMetadataBuilder builder = ObjectMetadataBuilder.create().key(key)
.contentType(metadata.getContentType())
.contentDisposition(metadata.getContentDisposition());
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,