Hello Adrian,
You are correct that containers == WebDAV folders.
I will use curl for these examples to keep it language agnostic.
Here is the directory structure I will create:
/Folder1/Folder2/readme.txt
This will be accessible using WebDAV using the path:
/dav/Folder1/Folder2/readme.txt
First we retrieve our rootContainer:
# curl -u <username>
https://example.com/v2 | xmlstarlet fo
# Enter host password for user '<username>':
<?xml version="1.0" encoding="UTF-8"?>
<cloud xmlns:xlink="http://www.w3.org/1999/xlink">
<rootContainer xlink:href="https://example.com/v2/containers/A7A59250-037E-11DE-A315-AB091792CCC5" xlink:type="simple"/>
<contacts xlink:href="https://example.com/v2/contacts" xlink:type="simple"/>
<shares xlink:href="https://example.com/v2/shares" xlink:type="simple"/>
<projects xlink:href="https://example.com/v2/projects" xlink:type="simple"/>
<metacontainers xlink:href="https://example.com/v2/metacontainers" xlink:type="simple"/>
<account xlink:href="https://example.com/v2/account" xlink:type="simple"/>
<tags xlink:href="https://example.com/v2/tags" xlink:type="simple"/>
<recyclebin xlink:href="https://example.com/v2/recyclebin" xlink:type="simple"/>
</cloud>
First we create the directory structure using the REST API.
Folder1 Creation:
# curl -u <username> -X POST -H 'Content-Type: application/vnd.csp.container-info+xml'
https://example.com/v2/containers/A7A59250-037E-11DE-A315-AB091792CCC5/contents -d <container><name>Folder1</name></container>
# Enter host password for user '<username>':
Response:
https://example.com/v2/containers/CC70F4F0-B1C8-11DE-A6F2-2BC186563653Folder2 Creation:
Notice the use of the Response URI in the second post to create a container within the contents of the first container that was created.
#curl -u <username> -X POST -H 'Content-Type: application/vnd.csp.container-info+xml'
https://example.com/v2/containers/CC70F4F0-B1C8-11DE-A6F2-2BC186563653/contents -d <container><name>Folder2</name></container>
# Enter host password for user '<username>':
Response:
https://example.com/v2/containers/34861C78-B1C9-11DE-B9A2-5FC690F26B5EWe now have the container hierarchy created:
/Folder1/Folder2
Let us add a file to this sub-container:
testfile.txt contents:
-----------------
This is test file
-----------------
# curl -u <username>
https://example.com/v2/containers/34861C78-B1C9-11DE-B9A2-5FC690F26B5E/contents -F "file=@testfile.txt;filename=testfile.txt"
# Enter host password for user '<username>':
Response:
https://example.com/v2/files/DDFF7948-B1C9-11DE-A575-0F1EFAB4E7D3Retrieve the file contents using REST to verify the contents:
# curl -u <username>
https://example.com/v2/files/DDFF7948-B1C9-11DE-A575-0F1EFAB4E7D3/contentResponse:
-----------------
This is test file
-----------------
Accessing the above-created file using WebDAV:
WebDAV keeps the same container structure that was builtup in the above example.
The only difference is that it prepends '/dav/' to the beginning of the URL.
This makes the URL to retrieve the file from:
https://example.com/dav/Folder1/Folder2/testfile.txtWebDAV uses GET to retrieve file contents:
# curl -u <username> -X GET
https://example.com/dav/Folder1/Folder2/testfile.txt # Enter host password for user '<username>':
-----------------
This is test file
-----------------