Search in sources :

Example 26 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testUploadZeroByteFile.

@Test
public void testUploadZeroByteFile() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDelegatingWriteFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid)));
    final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(0);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setLength(random.length);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) OutputStream(java.io.OutputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 27 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testUploadBelowMultipartSize.

@Test
public void testUploadBelowMultipartSize() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDelegatingWriteFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid)));
    final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(578);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setLength(random.length);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) OutputStream(java.io.OutputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 28 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testUploadExactMultipartSize.

@Test
public void testUploadExactMultipartSize() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDelegatingWriteFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid)));
    final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(10 * 1024 * 1024);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setLength(random.length);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(status.isComplete());
    assertNotNull(status.getResponse());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) OutputStream(java.io.OutputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 29 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testTripleCryptUploadBelowMultipartSize.

@Test
public void testTripleCryptUploadBelowMultipartSize() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid));
    final Path room = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(578);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setFilekey(nodeid.getFileKey());
    status.setLength(random.length);
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session, nodeid);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test, local), status), new DisabledConnectionCallback());
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(status.isComplete());
    assertNotNull(status.getResponse());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    final byte[] compare = new byte[random.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(test, new TransferStatus(), new DisabledConnectionCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(random, compare);
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) OutputStream(java.io.OutputStream) LoginOptions(ch.cyberduck.core.LoginOptions) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 30 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class DropboxUploadFeatureTest method testUploadSmall.

@Test
public void testUploadSmall() throws Exception {
    final DropboxUploadFeature feature = new DropboxUploadFeature(session, new DropboxWriteFeature(session));
    final Path root = new Path("/", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final String name = new AlphanumericRandomStringService().random();
    final Path test = new Path(root, name, EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), name);
    final int length = 56;
    final byte[] content = RandomUtils.nextBytes(length);
    IOUtils.write(content, local.getOutputStream(false));
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    status.setMime("text/plain");
    final BytecountStreamListener count = new BytecountStreamListener();
    final Metadata metadata = feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, status, new DisabledLoginCallback());
    assertEquals(content.length, count.getSent());
    assertTrue(status.isComplete());
    assertTrue(new DropboxFindFeature(session).find(test));
    final PathAttributes attributes = new DropboxAttributesFinderFeature(session).find(test);
    assertEquals(content.length, attributes.getSize());
    assertEquals(((FileMetadata) metadata).getContentHash(), attributes.getChecksum().hash);
    new DropboxDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) PathAttributes(ch.cyberduck.core.PathAttributes) FileMetadata(com.dropbox.core.v2.files.FileMetadata) Metadata(com.dropbox.core.v2.files.Metadata) Local(ch.cyberduck.core.Local) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractDropboxTest(ch.cyberduck.core.AbstractDropboxTest)

Aggregations

PathAttributes (ch.cyberduck.core.PathAttributes)291 Path (ch.cyberduck.core.Path)233 Test (org.junit.Test)200 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)176 IntegrationTest (ch.cyberduck.test.IntegrationTest)175 Delete (ch.cyberduck.core.features.Delete)153 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)143 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)139 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)74 ByteArrayInputStream (java.io.ByteArrayInputStream)55 StreamCopier (ch.cyberduck.core.io.StreamCopier)49 InputStream (java.io.InputStream)49 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)45 NotfoundException (ch.cyberduck.core.exception.NotfoundException)45 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)41 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)36 AttributedList (ch.cyberduck.core.AttributedList)34 Local (ch.cyberduck.core.Local)32 Host (ch.cyberduck.core.Host)31 OutputStream (java.io.OutputStream)31