diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index b2687255e7..4ebde2a729 100755 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -530,6 +530,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { blob.getMetadata().setSize(payload.getContentLength()); blob.getMetadata().setContentMD5(payload.getContentMD5()); blob.getMetadata().setContentType(payload.getContentType()); + blob.getMetadata().setContentDisposition(payload.getContentDisposition()); String eTag = CryptoStreams.hex(payload.getContentMD5()); blob.getMetadata().setETag(eTag); @@ -542,6 +543,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { Collections.singleton(payload.getContentLength() + "")); blob.getAllHeaders().replaceValues("Content-MD5", Collections.singleton(CryptoStreams.base64(payload.getContentMD5()))); + //TODO maybe i should change here content-disposition blob.getAllHeaders().putAll(Multimaps.forMap(blob.getMetadata().getUserMetadata())); return blob; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobMetadata.java index 866b3acd59..2f736f9660 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobMetadata.java @@ -41,4 +41,12 @@ public interface BlobMetadata extends StorageMetadata { byte[] getContentMD5(); + /** + * Content-Disposition to set for the blob. + *

+ * Attention: Not all provider support it! + * @return + */ + String getContentDisposition(); + } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableBlobMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableBlobMetadata.java index 4adfdd3bca..cd53155a05 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableBlobMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/MutableBlobMetadata.java @@ -43,4 +43,6 @@ public interface MutableBlobMetadata extends BlobMetadata, MutableStorageMetadat void setContentMD5(@Nullable byte[] md5); + String setContentDisposition(@Nullable String contentDisposition); + } \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobImpl.java index 339e1d25ad..69154d8ad3 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobImpl.java @@ -144,6 +144,7 @@ public class BlobImpl extends PayloadEnclosingImpl implements Blob, Comparable> responses = Maps.newHashMap(); for (int i = 0; i < 10; i++) { @@ -124,6 +125,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { public Void apply(Blob from) { try { assertEquals(CryptoStreams.md5(from.getPayload()), oneHundredOneConstitutionsMD5); + checkContentDispostion(from, expectedContentDisposition); } catch (IOException e) { Throwables.propagate(e); } @@ -142,14 +144,26 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { } - private void uploadConstitution(String containerName, String key) throws IOException { + private void uploadConstitution(String containerName, String key, String contentDisposition) throws IOException { Blob sourceObject = context.getBlobStore().newBlob(key); sourceObject.getMetadata().setContentType("text/plain"); sourceObject.getMetadata().setContentMD5(oneHundredOneConstitutionsMD5); + sourceObject.getMetadata().setContentDisposition(contentDisposition); sourceObject.setPayload(oneHundredOneConstitutions.getInput()); context.getBlobStore().putBlob(containerName, sourceObject); } + /** + * Methods for checking Content-Disposition. In this way, in implementations + * that do not support the new field, it is easy to override with empty, + * and allow the rest of the test to work. + * @param blob + * @param expected + */ + protected void checkContentDispostion(Blob blob, String expected){ + assertEquals(blob.getPayload().getContentDisposition(), expected); + } + @Test(groups = { "integration", "live" }) public void testGetIfModifiedSince() throws InterruptedException { String containerName = getContainerName(); diff --git a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java index a3ff826643..a86ab989a4 100644 --- a/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java +++ b/core/src/test/java/org/jclouds/http/BaseHttpCommandExecutorServiceIntegrationTest.java @@ -227,6 +227,7 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base assertEquals(client.postJson("", "foo").trim(), "{\"key\":\"foo\"}POST"); } + @Test(invocationCount = 5, timeOut = 5000) public void testPostContentDisposition() throws MalformedURLException, ExecutionException, InterruptedException, TimeoutException { assertEquals(client.postWithContentDisposition("", "attachment; filename=photo.jpg", "foo").trim(), "content-disposition:photo.jpg");