Package org.jclouds.io

Examples of org.jclouds.io.Payload.openStream()


      server.enqueue(mr);

      Payload payload = client.getJobOutput(VAULT_NAME, JOB_ID);
      assertThat(payload.getContentMetadata().getContentType()).isEqualTo(MediaType.JSON_UTF_8.toString());
      assertThat(payload.getContentMetadata().getContentLength()).isEqualTo(mr.getBody().length);
      assertThat(payload.openStream())
              .hasContentEqualTo(Resources.getResource(GlacierClientMockTest.class,
                      "/json/getJobOutputResponseBody.json").openStream());

      assertEquals(server.takeRequest().getRequestLine(),
              "GET /-/vaults/" + VAULT_NAME + "/jobs/" + JOB_ID + "/output " + HTTP);
View Full Code Here


      filesystemBlobKeyValidator.validate(blobKey);
      File outputFile = getFileForBlobKey(containerName, blobKey);
      HashingInputStream his = null;
      try {
         Files.createParentDirs(outputFile);
         his = new HashingInputStream(Hashing.md5(), payload.openStream());
         Files.asByteSink(outputFile).writeFrom(his);
         HashCode actualHashCode = his.hash();
         HashCode expectedHashCode = payload.getContentMetadata().getContentMD5AsHashCode();
         if (expectedHashCode != null && !actualHashCode.equals(expectedHashCode)) {
            throw new IOException("MD5 hash code mismatch, actual: " + actualHashCode +
View Full Code Here

        GetOptions getOptionsRangeStartAt = new GetOptions();
        getOptionsRangeStartAt.startAt(1);
        Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt);
        payload = blobRangeStartAt.getPayload();
        try {
            assertEquals(input.substring(1), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }

        GetOptions getOptionsRangeTail = new GetOptions();
View Full Code Here

        GetOptions getOptionsRangeTail = new GetOptions();
        getOptionsRangeTail.tail(3);
        Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail);
        payload = blobRangeTail.getPayload();
        try {
            assertEquals(input.substring(5), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }

        GetOptions getOptionsFragment = new GetOptions();
View Full Code Here

        GetOptions getOptionsFragment = new GetOptions();
        getOptionsFragment.range(4, 6);
        Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment);
        payload = blobFragment.getPayload();
        try {
            assertEquals(input.substring(4, 7), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }
    }
View Full Code Here

      SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
      try {
         client.connect();
         Payload etcPasswd = client.get("/etc/jclouds.txt");
         String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.openStream());
         assertEquals("rackspace", etcPasswdContents.trim());
      } finally {
         if (client != null)
            client.disconnect();
      }
View Full Code Here

      File payloadFile = File.createTempFile("testPutFileParallel", "png");
      createTestInput(32 * 1024).copyTo(Files.asByteSink(payloadFile));
     
      final Payload testPayload = Payloads.newFilePayload(payloadFile);
      final HashCode md5 = ByteStreams2.hashAndClose(testPayload.openStream(), md5());
      testPayload.getContentMetadata().setContentType("image/png");
     
      final AtomicInteger blobCount = new AtomicInteger();
      final String container = getContainerName();
      try {
View Full Code Here

         // Get the job output
         Payload result = client.getJobOutput(vaultName, jobId);

         // Print the result
         System.out.println("The retrieved payload is: " + Strings2.toStringAndClose(result.openStream()));
      } catch (InterruptedException e) {
         Throwables.propagate(e);
      }
   }
View Full Code Here

      // GET the file using jclouds
      File file = File.createTempFile(FILENAME, ".tmp");
      Payload payload = blobStoreContext.utils().http().invoke(request).getPayload();

      try {
         Files.asByteSink(file).writeFrom(payload.openStream());

         System.out.format("  GET Success (%s)%n", file.getAbsolutePath());
      } finally {
         payload.release();
         file.delete();
View Full Code Here

        GetOptions getOptionsRangeStartAt = new GetOptions();
        getOptionsRangeStartAt.startAt(1);
        Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt);
        payload = blobRangeStartAt.getPayload();
        try {
            assertEquals(input.substring(1), Strings2.toStringAndClose(payload.openStream()));
        } finally {
            Closeables2.closeQuietly(payload);
        }

        GetOptions getOptionsRangeTail = new GetOptions();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.