Uploading a file to File Drop using http post method

Dear Nextcloud team and devs,

I am trying to make my ruby application upload a zip file to a file drop folder in my nextcloud, but I only get 405 answers from nextcloud. Unfortunately, I was unable to find any documentation on how to do this or how such a post request is supposed to look like.
Can someone please hint me to what exact url and headers to use?

The only thing I found on that topic is this little curl script, but it did not help making it work (and it looks a bit outdated).

Thanks,
Amo

There is a client library in python, https://github.com/owncloud/pyocclient, perhaps this helps you to get some inspiration. I have only tried with a client login, never as a file drop.

And the API documentation:
https://docs.nextcloud.com/server/16/developer_manual/client_apis/index.html

Thank you a lot for pointing me to the right direction. It seems like I should be using a PUT request instead of a POST request.
Now I can get some results when testing with curl, though the upload is not successful yet.

The API documentation states that all requests need to provide authentication information, either as a Basic Auth header or by passing a set of valid session cookies. But this somehow defeats the purpose of having a public upload (file drop) page which does not need an account.

If I give curl test:test for user:password, just so to make it send an auth header, I get the error “No public access to this resource., Username or password was incorrect”.

Hi buddy, do trying looping from the custom login url that should solve it.

Regards,
Teju Bessey https://dltutuapp.com/tutuapp-download/ https://showbox.run/ https://kodi.software/

Thank you for the idea!

Unfortunately, I don’t really understand what you mean by looping from the login url… and which custom login url?

Could you please help me out with a few explanations or a quick example?

Ok so after a long time of searching and trying I figured out a way to do this. Here is my solution in case somebody happens to be trying the same thing:

In Ruby we can upload easily using the PUT (not POST) with the mechanize gem:

webdav_path = "public.php/webdav/files/user/folder/#{filename}"
full_url = "https://example.com/#{webdav_path}"
agent = Mechanize.new
agent.add_auth(full_url, 'folder', '')
agent.put(full_url, File.open(filename, "r").read, {'X-Requested-With' => 'XMLHttpRequest', 'Content-Type' => 'application/zip'})

Seemed important to set the X-Requested-With header, to use the webdav path and to set basic auth to the folder as username and empty password.

Another thing I found very helpful to figure this out is this cURL script.

Upload video file in nextcloud server through webdav npm but getting error

https://help.nextcloud.com/uploads/default/original/3X/0/6/06c45745f13bac45f55e42cae388f3e3d70d5e3f.png

I don’t know enough JS to help review any code, but looking at the screenshot, I can see that the error code is 409, which means it is a client error.

i use this npm library.

please see that library and it’s methods and guide me how to upload video on my next cloud server through node js.

As mentioned above, I can’t help you with nodejs as I’ve never used it.
Get some guidance from the official API documentation and test your queries with curl.

I don’t know how you are expecting to use a file upload link. The api docs state (as also mentioned a few posts above) that you have to use the PUT http method to upload a file, so I’d rather try this or this.