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