From 96db7ef36aa064c667c98d518e9005afc163c7f8 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Fri, 19 Apr 2024 14:35:59 +0200 Subject: [PATCH] Fix #15839. --- .../core/nextcloud/NextcloudShareFeature.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nextcloud/src/main/java/ch/cyberduck/core/nextcloud/NextcloudShareFeature.java b/nextcloud/src/main/java/ch/cyberduck/core/nextcloud/NextcloudShareFeature.java index 4d98a17edfd..349e07eea20 100644 --- a/nextcloud/src/main/java/ch/cyberduck/core/nextcloud/NextcloudShareFeature.java +++ b/nextcloud/src/main/java/ch/cyberduck/core/nextcloud/NextcloudShareFeature.java @@ -190,23 +190,21 @@ public DescriptiveUrl handleEntity(final HttpEntity entity) throws IOException { @Override public DescriptiveUrl toUploadUrl(final Path file, final Sharee sharee, final Object options, final PasswordCallback callback) throws BackgroundException { final Host bookmark = session.getHost(); - final StringBuilder request = new StringBuilder(String.format("https://%s/ocs/v1.php/apps/files_sharing/api/v1/shares", - bookmark.getHostname() + final StringBuilder request = new StringBuilder(String.format("https://%s/ocs/v1.php/apps/files_sharing/api/v1/shares?path=%s&shareType=%d&permissions=%d", + bookmark.getHostname(), + URIEncoder.encode(PathRelativizer.relativize(bookmark.getProtocol().getDefaultPath(), + PathRelativizer.relativize(new NextcloudHomeFeature(bookmark).find().getAbsolute(), file.getAbsolute()))), + Sharee.world.equals(sharee) ? SHARE_TYPE_PUBLIC_LINK : SHARE_TYPE_USER, + SHARE_PERMISSIONS_CREATE )); final Credentials password = callback.prompt(bookmark, LocaleFactory.localizedString("Passphrase", "Cryptomator"), MessageFormat.format(LocaleFactory.localizedString("Create a passphrase required to access {0}", "Credentials"), file.getName()), new LoginOptions().anonymous(true).keychain(false).icon(bookmark.getProtocol().disk())); if(password.isPasswordAuthentication()) { - request.append(String.format("?password=%s", URIEncoder.encode(password.getPassword()))); + request.append(String.format("&password=%s", URIEncoder.encode(password.getPassword()))); } final HttpPost resource = new HttpPost(request.toString()); - resource.setEntity(EntityBuilder.create().setContentType(ContentType.APPLICATION_JSON).setText(String.format("{\"path\":\"%s\",\"shareType\":%d,\"permissions\":%d}", - URIEncoder.encode(PathRelativizer.relativize(bookmark.getProtocol().getDefaultPath(), - PathRelativizer.relativize(new NextcloudHomeFeature(bookmark).find().getAbsolute(), file.getAbsolute()))), - Sharee.world.equals(sharee) ? SHARE_TYPE_PUBLIC_LINK : SHARE_TYPE_USER, - SHARE_PERMISSIONS_CREATE // Create - )).build()); resource.setHeader("OCS-APIRequest", "true"); resource.setHeader(HttpHeaders.ACCEPT, ContentType.APPLICATION_XML.getMimeType()); try {