Package org.jclouds.io.payloads

Examples of org.jclouds.io.payloads.InputStreamPayload


            public InputStream getInput() throws IOException {
                return cache.getInputStream();
            }
        });
        cache.reset();
        InputStreamPayload payload = new InputStreamPayload(cache.getInputStream());
        payload.getContentMetadata().setContentLength(contentLength);
        return payload;
    }
View Full Code Here


   }

   public void testWritePayloadOnFileInputStream() throws IOException {
      String blobKey = TestUtils.createRandomBlobKey("writePayload-", ".img");
      File sourceFile = TestUtils.getImageForBlobPayload();
      InputStreamPayload fileInputStreamPayload = new InputStreamPayload(
            new FileInputStream(sourceFile));
      Blob blob = storageStrategy.newBlob(blobKey);
      blob.setPayload(fileInputStreamPayload);

      // write files
View Full Code Here

         throw new UnsupportedOperationException("unsupported payload type: " + data.getClass());
      }
   }

   public static InputStreamPayload newInputStreamPayload(InputStream data) {
      return new InputStreamPayload(checkNotNull(data, "data"));
   }
View Full Code Here

   @Test
   public void testIterableSliceExpectedSingle() throws IOException {
      PayloadSlicer slicer = new BasePayloadSlicer();
      String contents = "aaaaaaaaaabbbbbbbbbbccccc";
      Payload payload = new InputStreamPayload(new ByteArrayInputStream(contents.getBytes(Charsets.US_ASCII)));

      Iterator<Payload> iter = slicer.slice(payload, 25).iterator();

      assertTrue(iter.hasNext(), "Not enough results");
      assertEquals(Strings2.toStringAndClose(iter.next().openStream()), contents);
View Full Code Here

   }

   @Test
   public void testIterableSliceExpectedMulti() throws IOException {
      PayloadSlicer slicer = new BasePayloadSlicer();
      Payload payload = new InputStreamPayload(new ByteArrayInputStream("aaaaaaaaaabbbbbbbbbbccccc".getBytes(Charsets.US_ASCII)));

      Iterator<Payload> iter = slicer.slice(payload, 10).iterator();

      assertTrue(iter.hasNext(), "Not enough results");
      assertEquals(Strings2.toStringAndClose(iter.next().getInput()), "aaaaaaaaaa");
View Full Code Here

TOP

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

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.