5

If I share access to a folder using a (temporary) link, anyone who knows the link and a password can upload files to that folder using the webinterface.

How can I script an upload to an owncloud folder that is shared via link?

For a regular user of the server, who has access to the webdav interface, the question is answered in Uploading files to an owncloud server programatically.

My actual use case is to upload build artifacts from a jenkins job. I do not want to use my own user account for security reasons, nor is our IT willing to create a pseudo-user.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Oliver Meyer
  • 413
  • 6
  • 7

3 Answers3

5
curl -u token:password -T filename "https://your.owncloud.server/public.php/webdav/filename"

The token is the string at the end of the shared link (e.g. abcdefghijk0123 in https://your.owncloud.server/index.php/s/abcdefghijk0123). If you don't use a password to protect the link you can leave the field in the command blank.

shebang
  • 51
  • 1
  • 1
  • 5
  • 1
    It does not work for me. Any idea what I am doing wrong? I shared a link, as `https://www.vpext.dsa-ac.de/dsacloud/index.php/s/rRLXrewsDIq4aRz` but the upload via `curl -u rRLXrewsDIq4aRz:pwd -T DefaultCatalog.xml "https://www.vpext.dsa-ac.de/dsacloud/public.php/webdav/DefaultCatalog.xml"` returns a `NotAuthenticated` exception. – Oliver Meyer Jan 13 '17 at 09:48
  • Was your shared link reachable via browser at this time? Maybe you could try without password for testing. – shebang Jan 14 '17 at 11:40
  • I got it working for the directory name, i.e. not the shared URL token, see https://stackoverflow.com/a/37921752/1184842 – jan Jul 07 '17 at 12:15
  • Maintained here: https://github.com/ceremcem/owncloud-tools/blob/master/upload.sh – ceremcem Sep 02 '19 at 01:49
2

If anybody is still looking for an answer to this question (it was the first google result for me), there is a solution for this in the OwnCloud admin-manual.

If you have not password-protected file drop link like

https://example.com/s/70mX9s7KOZwfmdi

(token 70mX9s7KOZwfmdi) you can upload a file file.txt from command line with the following cURL command:

curl -k -T file.txt -u "70mX9s7KOZwfmdi:" -H 'X-Requested-With: XMLHttpRequest' \https://example.com/public.php/webdav/file.txt

Source: https://doc.owncloud.com/server/next/user_manual/files/access_webdav.html#uploading-files-to-a-public-link-file-drop-using-curl

Zoe
  • 27,060
  • 21
  • 118
  • 148
jelkose
  • 21
  • 3
0

You could try to create an app password on https://your-owncloud-server/settings/personal#apppasswords, that way you wouldn't need an other user account.

Edit: only works on Nextcloud

  • I do not see such an options on my settings page. I do see `personal#clientsbox` `personal#passwordform` `persona#ssl-root-certificates`. – Oliver Meyer Nov 14 '16 at 08:30