If you need to download the entire directory instead of a single file via WebDAV, you can use the following approach.
Imagine that you have the following local folder that you are going to download via WebDAV.
local_folder_to_upload β test.txt β test1.txt β ββββnested_folder1 β β file1.txt β β file2.txt β β β ββββnested_folder2 β β file11.txt β β file12.txt
1. First you need to create subdirectories from your local folder (if any) on the server. Since WebDAV does not support recursive loading, you must do this in a separate step ( if you should use ftp , you would add --ftp-create-dirs to do this). To create these folders through WebDAV you need to use the MKCOL method .
curl -X MKCOL 'http://your.server/uploads/nested_folder1' --user 'name:pwd' curl -X MKCOL 'http://your.server/uploads/nested_folder1/nested_folder2' --user 'name:pwd'
Please note that you cannot create them in a single request according to the specification .
if a request is made to create the collection / a / b / c / d / and / a / b / c / does not exist, the request should fail.
2. Secondly, you can use the output of the find shell command to upload it to your server using curl .
cd local_folder_to_upload && find . -exec curl -T {} 'http://your.server/uploads/{}' --user 'name:pwd' \;
The above code iterates over all your files inside this directory (using find) and adds the output (file name with relative path) to the {} placeholder in your web server URL. Thus, he makes several requests (one for each file), and since all subfolders were created in advance, these requests should not fail.
Hope this will be helpful to someone.
Artyom Pranovich Nov 11 '18 at 10:00 p.m. 2018-11-11 22:00
source share