Package org.jclouds.s3.domain

Examples of org.jclouds.s3.domain.S3Object


   public void testPublicReadOnObject() throws InterruptedException, ExecutionException, TimeoutException, IOException {
      final String publicReadObjectKey = "public-read-acl";
      final String containerName = getContainerName();
      try {
         S3Object object = getApi().newS3Object();
         object.getMetadata().setKey(publicReadObjectKey);
         object.setPayload("");
         getApi().putObject(containerName, object, new PutObjectOptions().withAcl(CannedAccessPolicy.PUBLIC_READ));

         assertConsistencyAware(new Runnable() {
            public void run() {
               try {
View Full Code Here


      }

   }

   protected String addBlobToContainer(String sourceContainer, String key) {
      S3Object sourceObject = getApi().newS3Object();
      sourceObject.getMetadata().setKey(key);
      sourceObject.getMetadata().getContentMetadata().setContentType("text/xml");
      sourceObject.setPayload(TEST_STRING);
      return getApi().putObject(sourceContainer, sourceObject);
   }
View Full Code Here

   }

   protected S3Object validateObject(String sourceContainer, String key) throws InterruptedException,
            ExecutionException, TimeoutException, IOException {
      assertConsistencyAwareContainerSize(sourceContainer, 1);
      S3Object newObject = getApi().getObject(sourceContainer, key);
      assert newObject != null;
      assertEquals(Strings2.toStringAndClose(newObject.getPayload().openStream()), TEST_STRING);
      return newObject;
   }
View Full Code Here

   }

   public void testMetadataWithCacheControlAndContentDisposition() throws Exception {
      String key = "hello";

      S3Object object = getApi().newS3Object();
      object.getMetadata().setKey(key);
      object.setPayload(TEST_STRING);
      object.getMetadata().setCacheControl("no-cache");
      object.getMetadata().getContentMetadata().setContentDisposition("attachment; filename=hello.txt");
      String containerName = getContainerName();
      try {
         getApi().putObject(containerName, object);

         S3Object newObject = validateObject(containerName, key);
         assertCacheControl(newObject, "no-cache");
         assertEquals(newObject.getMetadata().getContentMetadata().getContentDisposition(),
                  "attachment; filename=hello.txt");
      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

   @Test(groups = { "integration", "live" })
   public void testMetadataContentEncoding() throws Exception {
      String key = "hello";

      S3Object object = getApi().newS3Object();
      object.getMetadata().setKey(key);
      object.setPayload(TEST_STRING);
      object.getMetadata().getContentMetadata().setContentEncoding("x-compress");
      String containerName = getContainerName();
      try {
         getApi().putObject(containerName, object);
         S3Object newObject = validateObject(containerName, key);
         assertContentEncoding(newObject, "x-compress");
      } finally {
         returnContainer(containerName);
      }
   }
View Full Code Here

                                               .addHeader("Authorization", "AWS identity:6gC0m7SYFDPwkUqY5EHV/6i9DfM=")
                                               .payload("hello world")
                                               .build();
                                   
      S3Client clientWhenBucketExists = requestSendsResponse(bucketFooExists, HttpResponse.builder().statusCode(200).addHeader(HttpHeaders.ETAG, "etag").build());
      S3Object object = clientWhenBucketExists.newS3Object();
      object.getMetadata().setKey("object");
      object.setPayload("hello world");
      Assert.assertEquals(clientWhenBucketExists.putObject("bucket", object), "etag");
   }
View Full Code Here

   }

   public S3Object apply(Blob from) {
      if (from == null)
         return null;
      S3Object object = objectProvider.create(blob2ObjectMd.apply(from.getMetadata()));
      object.setPayload(checkNotNull(from.getPayload(), "payload: " + from));
      object.setAllHeaders(from.getAllHeaders());
      return object;
   }
View Full Code Here

      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().addHeader(ETAG, "ABCDEF"));
      server.play();

      S3Client client = getS3Client(server.getUrl("/"));
      S3Object nada = client.newS3Object();
      nada.getMetadata().setKey("object");
      nada.setPayload(new byte[] {});

      assertEquals(client.putObject("bucket", nada), "ABCDEF");

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getRequestLine(), "PUT /bucket/object HTTP/1.1");
View Full Code Here

      MockWebServer server = new MockWebServer();
      server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
      server.play();

      S3Client client = getS3Client(server.getUrl("/"));
      S3Object fileInDir = client.newS3Object();
      fileInDir.getMetadata().setKey("someDir/fileName");
      fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });

      assertEquals(client.putObject("bucket", fileInDir), "ABCDEF");

      RecordedRequest request = server.takeRequest();
      assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
View Full Code Here

@Test(groups = "unit", testName = "BindS3ObjectMetadataToRequestTest")
public class BindS3ObjectMetadataToRequestTest extends BaseS3ClientTest<S3Client> {

   @Test
   public void testPassWithMinimumDetailsAndPayload5GB() {
      S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
      Payload payload = Payloads.newStringPayload("");
      payload.getContentMetadata().setContentLength(5368709120l);
      object.setPayload(payload);
      object.getMetadata().setKey("foo");

      HttpRequest request = HttpRequest.builder().method("PUT").endpoint("http://localhost").build();
      BindS3ObjectMetadataToRequest binder = injector.getInstance(BindS3ObjectMetadataToRequest.class);

      assertEquals(binder.bindToRequest(request, object), HttpRequest.builder().method("PUT").endpoint(
View Full Code Here

TOP

Related Classes of org.jclouds.s3.domain.S3Object

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.