@Override
public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService())
.getDetails(file, status);
final MultipartUpload multipart;
try {
multipart = session.getClient().multipartStartUpload(
containerService.getContainer(file).getName(), object);
if(log.isDebugEnabled()) {
log.debug(String.format("Multipart upload started for %s with ID %s",
multipart.getObjectKey(), multipart.getUploadId()));
}
}
catch(ServiceException e) {
throw new S3ExceptionMappingService().map("Upload {0} failed", e, file);
}
final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status);
return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy,
preferences.getInteger("s3.upload.multipart.partsize.minimum"))) {
@Override
public VersionId getStatus() {
return proxy.getVersionId();
}
};
}