a-schild/nextcloud-java-api

How can i share a file without sharing folder?

symax opened this issue · 0 comments

symax commented

Hello. I can easily share a folder with doShare method. But when i try to do the same with a file i have an error Nextcloud API call failed with statuscode 404 and message "Public upload is only possible for publicly shared folders"
And even if a file is in a shared folder i get the same error. I dont understand...
What did i do wrong? Is it possible to share a file only? Or how to resolve this error when i want to share a file from shared folder?
When i want to share my temp file from the cloud UI it works nice.

Example:

String testFolder = "test";
String testFile = "/test/temp.png";

ServerConfig _sc = new ServerConfig("cloud.mycloud.com", true, 443, user, pass);
FilesharingConnector fsc = new FilesharingConnector(_sc);
SharePermissions perm = new SharePermissions(SharePermissions.SingleRight.READ);

Share sFolder = fsc.doShare(testFolder, ShareType.PUBLIC_LINK, "", true,"1", perm);   //this one works fine
Share sFile = fsc.doShare(testFile, ShareType.PUBLIC_LINK, "", true, "1", perm); //error

UPD: When i try to share a folder after send "permissons=1" in response i get "permissions=15" somehow...
UPD2: Actually anything i write (READ, UPDATE, SHARE) turns into 15 in response.
UPD3: fsc.editShare(sFolder.getId(), ShareData.PERMISSIONS, "1") Works fine xD
UPD4: ok... fsc.doShare(testFile, ShareType.PUBLIC_LINK, null, null, "1234-Te$t", perm); Problem solved. But i cant delete the threat.