Search in sources :

Example 26 with DescriptiveUrl

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

the class SDSSharesUrlProviderTest method testUploadAccountSubRoom.

@Test
public void testUploadAccountSubRoom() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    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 SDSDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final DescriptiveUrl url = new SDSSharesUrlProvider(session, nodeid).toUploadUrl(test, new CreateUploadShareRequest().name(new AlphanumericRandomStringService().random()).expiration(new ObjectExpiration().enableExpiration(false)).notifyCreator(false).sendMail(false).sendSms(false).password(null).mailRecipients(null).mailSubject(null).mailBody(null).maxSize(null).maxSlots(null).notes(null).filesExpiryPeriod(null), new DisabledPasswordCallback());
    assertNotEquals(DescriptiveUrl.EMPTY, url);
    assertEquals(DescriptiveUrl.Type.signed, url.getType());
    assertTrue(url.getUrl().startsWith("https://duck.dracoon.com/#/public/shares-uploads/"));
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ObjectExpiration(ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) CreateUploadShareRequest(ch.cyberduck.core.sds.io.swagger.client.model.CreateUploadShareRequest) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 27 with DescriptiveUrl

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

the class SDSSharesUrlProviderTest method testToUrlInvalidEmail.

@Test(expected = InteroperabilityException.class)
public void testToUrlInvalidEmail() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    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 SDSTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    try {
        final DescriptiveUrl url = new SDSSharesUrlProvider(session, nodeid).toDownloadUrl(test, new CreateDownloadShareRequest().expiration(new ObjectExpiration().enableExpiration(false)).notifyCreator(false).sendMail(true).mailRecipients("a@b").sendSms(false).mailSubject(null).mailBody(null).maxDownloads(null), new DisabledPasswordCallback());
    } finally {
        new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ObjectExpiration(ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration) CreateDownloadShareRequest(ch.cyberduck.core.sds.io.swagger.client.model.CreateDownloadShareRequest) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 28 with DescriptiveUrl

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

the class SDSSharesUrlProviderTest method testUploadAccountTopLevelRoom.

@Test
public void testUploadAccountTopLevelRoom() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final DescriptiveUrl url = new SDSSharesUrlProvider(session, nodeid).toUploadUrl(room, new CreateUploadShareRequest().name(new AlphanumericRandomStringService().random()).expiration(new ObjectExpiration().enableExpiration(false)).notifyCreator(false).sendMail(false).sendSms(false).password(null).mailRecipients(null).mailSubject(null).mailBody(null).maxSize(null).maxSlots(null).notes(null).filesExpiryPeriod(null), new DisabledPasswordCallback());
    assertNotEquals(DescriptiveUrl.EMPTY, url);
    assertEquals(DescriptiveUrl.Type.signed, url.getType());
    assertTrue(url.getUrl().startsWith("https://duck.dracoon.com/#/public/shares-uploads/"));
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ObjectExpiration(ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) CreateUploadShareRequest(ch.cyberduck.core.sds.io.swagger.client.model.CreateUploadShareRequest) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 29 with DescriptiveUrl

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

the class SDSSharesUrlProviderTest method testToUrlExpiry.

@Test
public void testToUrlExpiry() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    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 SDSTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final DescriptiveUrl url = new SDSSharesUrlProvider(session, nodeid).toDownloadUrl(test, new CreateDownloadShareRequest().expiration(new ObjectExpiration().enableExpiration(true).expireAt(new DateTime(1744300800000L))).notifyCreator(false).sendMail(false).sendSms(false).password(null).mailRecipients(null).mailSubject(null).mailBody(null).maxDownloads(null), new DisabledPasswordCallback());
    assertNotEquals(DescriptiveUrl.EMPTY, url);
    assertEquals(DescriptiveUrl.Type.signed, url.getType());
    assertTrue(url.getUrl().startsWith("https://duck.dracoon.com/#/public/shares-downloads/"));
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) ObjectExpiration(ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration) CreateDownloadShareRequest(ch.cyberduck.core.sds.io.swagger.client.model.CreateDownloadShareRequest) DateTime(org.joda.time.DateTime) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 30 with DescriptiveUrl

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

the class DropboxTemporaryUrlProvider method toDownloadUrl.

@Override
public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException {
    try {
        if (log.isDebugEnabled()) {
            log.debug(String.format("Create temporary link for %s", file));
        }
        // This link will expire in four hours and afterwards you will get 410 Gone.
        final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink();
        // Determine expiry time for URL
        final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiry.add(Calendar.HOUR, 4);
        return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())));
    } catch (DbxException e) {
        throw new DropboxExceptionMappingService().map(e);
    }
}
Also used : DbxUserFilesRequests(com.dropbox.core.v2.files.DbxUserFilesRequests) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) Calendar(java.util.Calendar) DbxException(com.dropbox.core.DbxException)

Aggregations

DescriptiveUrl (ch.cyberduck.core.DescriptiveUrl)77 Path (ch.cyberduck.core.Path)42 Test (org.junit.Test)40 IntegrationTest (ch.cyberduck.test.IntegrationTest)30 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)25 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)24 Delete (ch.cyberduck.core.features.Delete)24 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)22 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)22 Host (ch.cyberduck.core.Host)19 DescriptiveUrlBag (ch.cyberduck.core.DescriptiveUrlBag)16 ObjectExpiration (ch.cyberduck.core.sds.io.swagger.client.model.ObjectExpiration)14 LoginOptions (ch.cyberduck.core.LoginOptions)13 CreateDownloadShareRequest (ch.cyberduck.core.sds.io.swagger.client.model.CreateDownloadShareRequest)12 Credentials (ch.cyberduck.core.Credentials)8 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)7 LoginCanceledException (ch.cyberduck.core.exception.LoginCanceledException)7 PathAttributes (ch.cyberduck.core.PathAttributes)6 IOException (java.io.IOException)6 HostUrlProvider (ch.cyberduck.core.HostUrlProvider)5