How to upload a file via CLI to Nextcloud? (bash)

Hello,

on one of my servers I run a script.
That script writes a log file and I want to upload that log file to my Nextcloud.

Binary “nextcloudcmd” provided by the client is not an option because I don’t want to sync, just uploading a file instead and delete it afterwards.

Tried cadaver but did not succeed.
Has anybody a hint for me to get this done in a bash script? Maybe I am blind.
Best way would be to show some code. :hugs:

Or another tool?

Specs Nextcloud:
Version 18

Specs server:
OS is Ubuntu 19.04

Would you like to smile :slight_smile:?
Current workaround: Transfer the file via scp to third machine. There is the desktop client running and syncing the log file to my Nextcloud :wink:
Darkside: The third machine is not running all the time (saves energy) and here the trouble starts :sweat:

I would use cURL like described in the documentation:

curl -u USERNAME:PASSWORD -T /path/to/file https://my.nextcloud.com/remote.php/dav/files/USERNAME/
2 Likes

Yes, the interface isn’t really meant to be scripted. (I tried that too, but gave up).
I’d propose using Curl, it’s capable of using any Webdav verb.

1 Like

Hey @Bernie_O,

you made my day. Adapted my scripts and removed workarounds.

Thank you.

1 Like