Bind Swift content metadata in multipart upload

This commit is contained in:
Andrew Gaul 2015-01-08 15:15:55 -08:00
parent 317089c77e
commit e8f925225c
2 changed files with 19 additions and 2 deletions

View File

@ -369,11 +369,23 @@ public interface CommonSwiftClient extends Closeable {
* {@link org.jclouds.openstack.swift.v1.features.ObjectApi#replaceManifest()}
*/
@Deprecated
@Named("PutObjectManifest")
@PUT
@Path("/{container}/{name}")
@ResponseParser(ParseETagHeader.class)
@Headers(keys = "X-Object-Manifest", values = "{container}/{name}/")
String putObjectManifest(@PathParam("container") String container, @PathParam("name") String name);
/**
* @deprecated This method will be replaced by
* {@link org.jclouds.openstack.swift.v1.features.ObjectApi#replaceManifest()}
*/
@Deprecated
@Named("PutObjectManifest")
@PUT
@Path("/{container}/{name}")
@ResponseParser(ParseETagHeader.class)
@Headers(keys = "X-Object-Manifest", values = "{container}/{name}/")
String putObjectManifest(@PathParam("container") String container, @PathParam("name") @ParamParser(ObjectName.class)
@BinderParam(BindSwiftObjectMetadataToRequest.class) SwiftObject object);
}

View File

@ -30,6 +30,7 @@ import org.jclouds.io.PayloadSlicer;
import org.jclouds.logging.Logger;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.blobstore.functions.BlobToObject;
import org.jclouds.openstack.swift.domain.SwiftObject;
import com.google.inject.Inject;
@ -78,7 +79,11 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg
.build();
client.putObject(container, blob2Object.apply(blobPart));
}
return client.putObjectManifest(container, key);
SwiftObject manifest = blob2Object.apply(blob);
// put empty manifest object retaining existing metadata
manifest.getPayload().getContentMetadata().setContentLength(0L);
return client.putObjectManifest(container, manifest);
} else {
return client.putObject(container, blob2Object.apply(blob));
}