I want to upload files to my nextcloud server. The problem is that I got an error. The first curl command should create the directory.
curl -u "$USER":"$PW" -X MKCOL "https://MYSERVER/remote.php/dav/files/$USER/$MANY_DIRECTORIES"
curl -u "$USER":"$PW" -T "$FILE" "https://MYSERVER/remote.php/dav/files/$USER/$MANY_DIRECTORIES/$FILE"
If $MANY_DIRECTORIES
contains just one directory it works. But if this variable contains e.g. /root/deep/deeper
and deep
doesn't exist I got this error:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\Conflict</s:exception>
<s:message>Parent node does not exist</s:message>
</d:error>
The second command throws this error:
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:exception>Sabre\DAV\Exception\NotFound</s:exception>
<s:message>File with name //test could not be located</s:message>
</d:error>
So how can I create the directories recursive to upload the file?
Thanks.