Need help with sending a file to python.

I have a problem uploading a file to my nextcloud server, I created a shared folder and I have a task to upload to this shared folder without authorization just using a link that gives access to it.

Honestly, I do not know much about this. I can give you just general advice.

First, I thought this might be brittle by design. If the API endpoints are OCS ones, everything is right but if they are plain rest endpoints they might change anytime. So, be warned and check that soon (see below).

I would open the dev tools of the browser and then upload a file. There should be a post request it something similar started. I would analyse this in the browser (reverse engineering to some point) to see what app and what routes are involved. Is there some sort of CSRF included? Is there anything out of normal to be considered? Especially you can check if the url is of the form of a OCS URL.

Then, I would have a look at the appropriate app in Nextcloud (probably in the server repository located) and see what the endpoint does and what it expects.

I hope this gives you a first starting point. At least I would try it that way for now. There might be some documentation but I did not find it quickly.

Christian

There is a Nextcloud client library for Python. I did not test it myself, it is quit old but it should do what you are looking for:

hope that helps,
much luck!

All you need is here:
Nextcloud Python Framework

There is examples of downloading and uploading files, if you need something complex and you can not find it in docs - feel free to ask.

1 Like