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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations