Create a folder and share link programatically

Hi,
I uploaded and installed nextcloud on my subdomain. Iam the owner of the domains.
If I would like to create a new folder and share this folder (to public with a url), I can do this in nextcloud directly via mouse clicks - no problem.
So is it possible to make that programatically with php? If yes, wich steps must i do?

For example:

  1. create a folder (mkdir)
  2. register that folder somewhere…?
  3. create a public link for sharing that folder…?
  4. …?

I hope you can help me. Sorry for my bad english.
Best regards

Really no one?

Patience young padawan :wink:

I am by no means a php programmer, but maybe you can accomlish what you want by reading this: https://docs.nextcloud.com/server/12/developer_manual/core/ocs-share-api.html

Note: This is for NC13, look at the specific documentation of your NC version.

Thank you! :blush:
Sharing methods works, but i dont found methods for creating files/folders… please help me :thinking:

just curl them in like

curl -X PUT -k -u user:pw --data-binary @D:\curl\test.txt https://domain.com/remote.php/webdav/test.txt

you could also just put the files in datadirectory and then use:

sudo -u www-data php occ files:scan

The fist possibility is the clean one. Rescanning all the time is not recommended for performannce reasons.

Thats exactly what iam searching for. Many thanks ! :+1:t2:

1 Like