我想将文件上传到我的nextcloud服务器。问题是我得到了一个错误。第一个curl命令应该会创建目录。
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"如果$MANY_DIRECTORIES只包含一个目录,它就可以工作。但是如果这个变量包含/root/deep/deeper,而deep不存在,我会得到这样的错误:
<?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>第二个命令抛出这个错误:
<?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>那么我如何创建递归的目录来上传文件呢?
谢谢。
发布于 2017-03-22 23:39:40
没有创建递归目录的选项,所以我将变量拆分为一个数组,并逐个创建目录。
IFS='/' read -r -a array <<<"$2"
for el in "${array[@]}"
do
TEMP=$TEMP/$el
curl -u "$USER:$PW" \
-X MKCOL \
"https://MYSERVER/remote.php/dav/files/$USER$TEMP"
done
curl -u "$USER:$PW" \
-T "$1" "https://MYSERVER/remote.php/dav/files/$USER/$2/$1"https://stackoverflow.com/questions/42941176
复制相似问题