Package org.jclouds.io.payloads

Examples of org.jclouds.io.payloads.ByteSourcePayload


      }
      return new InputStreamPayload(ByteStreams.limit(content, length));
   }

   protected Payload doSlice(ByteSource content, long offset, long length) {
      return new ByteSourcePayload(content.slice(offset, length));
   }
View Full Code Here


   protected Payload doSlice(byte[] content, long offset, long length) {
      Payload returnVal;
      checkArgument(offset <= Integer.MAX_VALUE, "offset is too big for an array");
      checkArgument(length <= Integer.MAX_VALUE, "length is too big for an array");
      returnVal = new ByteSourcePayload(ByteSource.wrap(content).slice(offset, length));
      return returnVal;
   }
View Full Code Here

   public static ByteArrayPayload newByteArrayPayload(byte[] data) {
      return new ByteArrayPayload(checkNotNull(data, "data"));
   }

   public static ByteSourcePayload newByteSourcePayload(ByteSource data) {
      return new ByteSourcePayload(checkNotNull(data, "data"));
   }
View Full Code Here

      }
   }

   public void testExtractArchive() throws Exception {
      for (String regionId : regions) {
         Payload payload = new ByteSourcePayload(ByteSource.wrap(tarGz));

         ExtractArchiveResponse extractResponse = api.getBulkApiForRegion(regionId)
                                                     .extractArchive(containerName, payload, "tar.gz");
         assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
         assertTrue(extractResponse.getErrors().isEmpty());
View Full Code Here

         overrides.setProperty(PROPERTY_MAX_RETRIES, 0 + ""); // 0 retries == 1 try. Semantics.
         overrides.setProperty(PROPERTY_RETRY_DELAY_START, 0 + ""); // exponential backoff already working for this call. This is the delay BETWEEN attempts.

         final SwiftApi api = api(server.getUrl("/").toString(), "openstack-swift", overrides);
        
         api.getObjectApiForRegionAndContainer("DFW", "myContainer").put("myObject", new ByteSourcePayload(ByteSource.wrap("swifty".getBytes())), metadata(metadata));

         fail("testReplaceTimeout test should have failed with an HttpResponseException.");
      } finally {
         server.shutdown();
      }
View Full Code Here

    long timeout = System.currentTimeMillis() + waitTime;
    while (!isFileCopied && System.currentTimeMillis() < timeout) {
      final SshjSshClient client = getSSHClient(host, privateKey);
      Assert.isTrue(file.exists(), "File to be copied to remote machine does not exist");
      ByteSource byteSource = com.google.common.io.Files.asByteSource(file);
      ByteSourcePayload payload = new ByteSourcePayload(byteSource);
      long byteSourceSize = -1;
      try {
        byteSourceSize = byteSource.size();
        payload.getContentMetadata().setContentLength(byteSourceSize);
      }
      catch (IOException ioe) {
        throw new IllegalStateException("Unable to retrieve size for file to be copied to remote machine.", ioe);
      }
      client.put(uri.getPath(), payload);
View Full Code Here

    public void testHttpClient() throws Exception {
        HttpClient httpClient = context.utils().http();
        // TODO: how to interpret this?
        URI uri = URI.create(s3Endpoint + "/container/blob");
        ByteSource byteSource = ByteSource.wrap(new byte[1]);
        Payload payload = new ByteSourcePayload(byteSource);
        payload.getContentMetadata().setContentLength(byteSource.size());
        httpClient.put(uri, payload);
        try (InputStream actual = httpClient.get(uri);
             InputStream expected = byteSource.openStream()) {
            assertThat(actual).hasContentEqualTo(expected);
        }
View Full Code Here

               .addHeader("Accept", MediaType.APPLICATION_JSON)
               .payload(payloadFromStringWithContentType(payload, "application/x-www-form-urlencoded")).build();
   }

   protected Payload staticPayloadFromResource(String resource) {
      return new ByteSourcePayload(Resources.asByteSource(Resources.getResource(getClass(), resource)));
   }
View Full Code Here

      // Create a vault
      final String vaultName =  "jclouds_providerExample_" + UUID.randomUUID().toString();
      client.createVault(vaultName);

      // Upload an archive
      Payload payload = new ByteSourcePayload(buildData(16));
      payload.getContentMetadata().setContentType(PLAIN_TEXT_UTF_8.toString());
      payload.getContentMetadata().setContentLength(16L);
      String archiveId = client.uploadArchive(vaultName, payload);

      // Create an archive retrieval job request
      JobRequest archiveRetrievalJobRequest = ArchiveRetrievalJobRequest.builder()
            .archiveId(archiveId)
View Full Code Here

      }
   }

   public void testExtractArchive() throws Exception {
      for (String regionId : regions) {
         Payload payload = new ByteSourcePayload(ByteSource.wrap(tarGz));

         ExtractArchiveResponse extractResponse = api.getBulkApiForRegion(regionId)
                                                     .extractArchive(containerName, payload, "tar.gz");
         assertEquals(extractResponse.getCreated(), OBJECT_COUNT);
         assertTrue(extractResponse.getErrors().isEmpty());
View Full Code Here

TOP

Related Classes of org.jclouds.io.payloads.ByteSourcePayload

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.