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:
create a folder (mkdir)
register that folder somewhere…?
create a public link for sharing that folder…?
…?
I hope you can help me. Sorry for my bad english.
Best regards
Patience young padawan
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!
Sharing methods works, but i dont found methods for creating files/folders… please help me
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 Like
xeruf
March 29, 2023, 9:34pm
7
Hey, would you mind sharing the curl command you used for creating the shares as well, or the whole script you made in the end?
Quite old topic, but it could help someone looking arround with the keywords.
There’s an up-to-date python library now tested on NextCloud 28:
creating a folder and share it:
import sys
from nc_py_api import (
FilePermissions,
Nextcloud,
ShareType,
)
username = "admin"
password = "your_password"
nextcloud_url = "https://your.nextcloud.url"
if __name__ == "__main__":
nc = Nextcloud(nextcloud_url=nextcloud_url, nc_auth_user=username, nc_auth_pass=password)
share_with = sys.argv[1]
new_folder_path = f"/some_path/{share_with}"
nc.files.mkdir(new_folder_path)
nc.files.sharing.create(path=new_folder_path,
share_type=ShareType.TYPE_USER,
share_with=share_with,
)
hope that helps.