How can I use the OwnCloud API or occ command to share a directory with a 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: https://doc.owncloud.com/server/next/developer_manual/core/apis/ocs-share-api.html#create-a-new-share
Gabriel Espejo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.