Search in sources :

Example 1 with CopyInterface

use of org.webpieces.googlecloud.storage.api.CopyInterface in project webpieces by deanhiller.

the class TestLocalStorage method testCopyFromClassPath.

@Test
public void testCopyFromClassPath() throws IOException {
    String bucketName = "testbucket";
    String blobName = "mytest.txt";
    String copyBlobName = "mytest_copy.txt";
    Storage.CopyRequest request = Storage.CopyRequest.newBuilder().setSource(BlobId.of(bucketName, blobName)).setTarget(BlobId.of(bucketName, copyBlobName)).build();
    Page<GCPBlob> testbucket = instance.list("copybucket");
    CopyInterface copy = instance.copy(request);
    ReadableByteChannel readFile = instance.reader("copybucket", "mytest_copy.txt");
    InputStream i = Channels.newInputStream(readFile);
    String text = new BufferedReader(new InputStreamReader(i, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
    // Passed.
    Assert.assertEquals("Some Test", text);
}
Also used : ReadableByteChannel(java.nio.channels.ReadableByteChannel) GCPStorage(org.webpieces.googlecloud.storage.api.GCPStorage) GCPBlob(org.webpieces.googlecloud.storage.api.GCPBlob) CopyInterface(org.webpieces.googlecloud.storage.api.CopyInterface) Test(org.junit.Test)

Aggregations

ReadableByteChannel (java.nio.channels.ReadableByteChannel)1 Test (org.junit.Test)1 CopyInterface (org.webpieces.googlecloud.storage.api.CopyInterface)1 GCPBlob (org.webpieces.googlecloud.storage.api.GCPBlob)1 GCPStorage (org.webpieces.googlecloud.storage.api.GCPStorage)1