Uploading to ownCloud (@EMBL) from command-line
EMBL provides an ownCloud server with (as of March 2021) 50GiB of storage for every EMBL user. To access it navigate to oc.embl.de and login using your EMBL credentials.
An alternative to Google Docs/Drive
You can use this system much like Google Docs or Google Drive by storing and sharing files or using the built in tools to edit documents.
Programmatic access
Besides public and private links for download and upload, Owncloud provides a WebDAV interface that can be used for programmatic access.
You can find the WebDAV URL for your user by logging in to oc.embl.de and clicking the Settings option in the bottom left corner of the screen.
Programmatic upload
Lets assume we have a file called hello.txt
that we want to upload to a folder called uploads
in your oc.embl.de account.
We can start by creating the test file.
echo 'Hello Owncloud!' > hello.txt
As we will need to use your account password, we can use the read
command to type it without accidentally adding it to the shell history.
Execute the next command, type your password and press Enter/Return.
read -s PASSWORD
You can confirm that the command worked by executing the next command that will display your password on screen:
echo $PASSWORD
In order to upload the file into a uploads
folder we must first create the folder.
This can be achieved using the MKCOL
instruction using curl
and your WebDAV URL.
curl -X MKCOL -u username:$PASSWORD "https://oc.embl.de/remote.php/dav/files/.../uploads"
where username
should be your EMBL username,
...
should be a unique identifier part of the WebDAV URL you copied above
and the /uploads
part indicates the folder name we want to create.
If you received an error in this step, verify that your username, password and WebDAV URL are correct.
Once successful, if you refresh your browser you should now see an uploads
folder.
We are now ready to upload our hello.txt
file which we can do with:
curl -X PUT -u username:$PASSWORD "https://oc.embl.de/remote.php/dav/files/.../uploads/hello-in-owncloud.txt" --data-binary @"hello.txt"
notice that we now use a PUT
instruction instead of MKCOL
,
the URL ends in uploads/hello-in-owncloud.txt
to indicate the folder and filename we want to create
and @"hello.txt"
indicates the name of the file in your computer.
If successful you should now see a hello-in-owncloud.txt
file inside the uploads
folder when visiting oc.embl.de.
Finally to clear the password stored in $PASSWORD
simply close the shell or execute:
unset PASSWORD
Additional WebDAV instructions
Besides MKCOL
and PUT
, WebDAV supports MOVE
and PROPFIND
instructions.
You can read more about these in the ownCloud official documentation.