Search in sources :

Example 1 with FileSharesApi

use of ch.cyberduck.core.storegate.io.swagger.client.api.FileSharesApi in project cyberduck by iterate-ch.

the class StoregateShareFeature method toDownloadUrl.

@Override
public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException {
    try {
        final Host bookmark = session.getHost();
        final CreateFileShareRequest request = new CreateFileShareRequest().fileId(fileid.getFileId(file, new DisabledListProgressListener()));
        try {
            request.setPassword(callback.prompt(bookmark, LocaleFactory.localizedString("Passphrase", "Cryptomator"), MessageFormat.format(LocaleFactory.localizedString("Create a passphrase required to access {0}", "Credentials"), file.getName()), new LoginOptions().keychain(false).icon(bookmark.getProtocol().disk())).getPassword());
        } catch (LoginCanceledException e) {
        // Ignore no password set
        }
        return new DescriptiveUrl(URI.create(new FileSharesApi(session.getClient()).fileSharesPost(request).getUrl()), DescriptiveUrl.Type.signed);
    } catch (ApiException e) {
        throw new StoregateExceptionMappingService(fileid).map(e);
    }
}
Also used : LoginOptions(ch.cyberduck.core.LoginOptions) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) FileSharesApi(ch.cyberduck.core.storegate.io.swagger.client.api.FileSharesApi) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) CreateFileShareRequest(ch.cyberduck.core.storegate.io.swagger.client.model.CreateFileShareRequest) ApiException(ch.cyberduck.core.storegate.io.swagger.client.ApiException)

Example 2 with FileSharesApi

use of ch.cyberduck.core.storegate.io.swagger.client.api.FileSharesApi in project cyberduck by iterate-ch.

the class StoregateShareFeature method toUploadUrl.

@Override
public DescriptiveUrl toUploadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException {
    try {
        final Host bookmark = session.getHost();
        final CreateFileShareRequest request = new CreateFileShareRequest().fileId(fileid.getFileId(file, new DisabledListProgressListener())).allowUpload(true);
        try {
            request.setPassword(callback.prompt(bookmark, LocaleFactory.localizedString("Passphrase", "Cryptomator"), MessageFormat.format(LocaleFactory.localizedString("Create a passphrase required to access {0}", "Credentials"), file.getName()), new LoginOptions().keychain(false).icon(bookmark.getProtocol().disk())).getPassword());
        } catch (LoginCanceledException e) {
        // Ignore no password set
        }
        return new DescriptiveUrl(URI.create(new FileSharesApi(session.getClient()).fileSharesPost(request).getUrl()), DescriptiveUrl.Type.signed);
    } catch (ApiException e) {
        throw new StoregateExceptionMappingService(fileid).map(e);
    }
}
Also used : LoginOptions(ch.cyberduck.core.LoginOptions) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) FileSharesApi(ch.cyberduck.core.storegate.io.swagger.client.api.FileSharesApi) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) CreateFileShareRequest(ch.cyberduck.core.storegate.io.swagger.client.model.CreateFileShareRequest) ApiException(ch.cyberduck.core.storegate.io.swagger.client.ApiException)

Aggregations

DescriptiveUrl (ch.cyberduck.core.DescriptiveUrl)2 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)2 Host (ch.cyberduck.core.Host)2 LoginOptions (ch.cyberduck.core.LoginOptions)2 LoginCanceledException (ch.cyberduck.core.exception.LoginCanceledException)2 ApiException (ch.cyberduck.core.storegate.io.swagger.client.ApiException)2 FileSharesApi (ch.cyberduck.core.storegate.io.swagger.client.api.FileSharesApi)2 CreateFileShareRequest (ch.cyberduck.core.storegate.io.swagger.client.model.CreateFileShareRequest)2