How can I use the OwnCloud API or occ command to share a directory with an user, granting them read and write permissions, but restricting their ability to delete files they have uploaded?
I’m using a shell script with the following command:
curl -k -u "${ADMIN}:${ADMIN_PASS}" -X POST ${OWNCLOUD_URL}/ocs/v2.php/apps/files_sharing/api/v1/shares" -d path="/${username}/share_dir"
-d shareType=0
-d shareWith="${username}"
-d permissions=15
I’ve noticed in the documentation that the permissions are as follows:
- 1 = read (default for public link shares);
- 2 = update;
- 4 = create;
- 8 = delete;
- 15 = read/write;
- 16 = share;
- 31 = All permissions.
However, when I try combinations without including permission 8, it doesn’t work. If I give permission 4, for example, the user can’t see the directory. And the combination 14 is interpreted as permission 1. The combination 15 gives permissions to delete as well.
Documentation: OCS Share API