diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayload.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayload.java index d40e642516..656cdfde10 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayload.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayload.java @@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkArgument; import javax.inject.Inject; import javax.inject.Singleton; +import javax.ws.rs.core.MediaType; import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix; import org.jclouds.http.HttpRequest; @@ -44,6 +45,8 @@ public class BindCFObjectToPayload implements Binder { public void bindToRequest(HttpRequest request, Object payload) { CFObject object = (CFObject) payload; + if (object.getPayload().getContentType() == null) + object.getPayload().setContentType(MediaType.APPLICATION_OCTET_STREAM); if (object.getPayload().getContentLength() != null && object.getPayload().getContentLength() >= 0) { checkArgument(object.getPayload().getContentLength() <= 5l * 1024 * 1024 * 1024, diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java index d8e2fb94df..d2676178cd 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java @@ -23,6 +23,8 @@ import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.verify; +import javax.ws.rs.core.MediaType; + import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix; import org.jclouds.blobstore.domain.Blob; import org.jclouds.http.HttpRequest; @@ -53,6 +55,8 @@ public class BindCFObjectToPayloadTest { MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class); expect(object.getPayload()).andReturn(payload).atLeastOnce(); + expect(payload.getContentType()).andReturn(null).atLeastOnce(); + payload.setContentType(MediaType.APPLICATION_OCTET_STREAM); expect(payload.getContentLength()).andReturn(5368709120l).atLeastOnce(); expect(object2Blob.apply(object)).andReturn(blob); mdBinder.bindToRequest(request, blob); @@ -93,6 +97,8 @@ public class BindCFObjectToPayloadTest { Multimap headers = createMock(Multimap.class); expect(object.getPayload()).andReturn(payload).atLeastOnce(); + expect(payload.getContentType()).andReturn(null).atLeastOnce(); + payload.setContentType(MediaType.APPLICATION_OCTET_STREAM); expect(payload.getContentLength()).andReturn(null).atLeastOnce(); expect(object2Blob.apply(object)).andReturn(blob); mdBinder.bindToRequest(request, blob); @@ -135,6 +141,8 @@ public class BindCFObjectToPayloadTest { MutableObjectInfoWithMetadata md = createMock(MutableObjectInfoWithMetadata.class); expect(object.getPayload()).andReturn(payload).atLeastOnce(); + expect(payload.getContentType()).andReturn(null).atLeastOnce(); + payload.setContentType(MediaType.APPLICATION_OCTET_STREAM); expect(payload.getContentLength()).andReturn(5368709121l).atLeastOnce(); expect(object2Blob.apply(object)).andReturn(blob); mdBinder.bindToRequest(request, blob);