Take full control of your storage using our API
If you prefer to use your custom solution to manage your online data storage, without using a browser, you can use our API. On this page, you can find examples of how to work with our API. We will continue to expand it and add more info over time to make the work with the API as easy as possible for you. If you have any comments, ideas or questions about this feature, please feel free to email us at support@myairbridge.com.
WebDAV basics
Introduction
- You can use curl for all calls.
Authentication
- You can authenticate using Basic authentication header.
- Or just add
--user "username:password"
to yourcurl
calls. - For password-only protected directories
guest
will always work as a username (e.g.guest:password
).
Overwrite header
- If the header is missing,
T
is the default value. F
value = Target files/directories are protected against overwriting.T
value = Target files/directories will be overwritten if they exist. Directories are not merged but completely replaced.
Get node details
-
PROPFIND
HTTP method is defined in RFC2518.
XML namespaces
URI | Prefix |
---|---|
DAV: | d: |
https://xml.myairbridge.cloud/ns | m: |
Node properties
Property | Note | Dir | File |
---|---|---|---|
d:href |
You should avoid using this URL. It is here only for compatibility with native WebDAV clients. Use m:node-url instead. |
Yes | Yes |
m:node-url |
URL of this node. | Yes | Yes |
d:creationdate |
Records the time and date the resource was created | Yes | Yes |
d:displayname |
Provides a name for the resource that is suitable for presentation to a user. | Yes | Yes |
d:getcontentlength |
Node size in bytes. | Yes | Yes |
d:getetag |
Unique ETag. | No | Yes |
d:getlastmodified |
Last-modified date. | Yes | Yes |
d:quota-available-bytes |
Free available storage size in bytes | Yes | No |
d:resourcetype |
Contains d:collection element if the node is a directory. |
Yes | Yes |
Example
curl -X PROPFIND 'DIRECTORY_URL'
Response:
<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:m="https://xml.myairbridge.cloud/ns">
<d:response>
<d:href>DIRECTORY_URL</d:href>
<m:node-url>DIRECTORY_URL</m:node-url>
<d:propstat>
<d:prop>
<d:creationdate>Mon, 01 Jan 2024 00:00:00 GMT</d:creationdate>
<d:getcontentlength>123456</d:getcontentlength>
<d:displayname>Directory name</d:displayname>
<d:getlastmodified>Mon, 01 Jan 2024 00:00:00 GMT</d:getlastmodified>
<d:resourcetype>
<d:collection/>
</d:resourcetype>
<d:quota-available-bytes>5497558015424</d:quota-available-bytes>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>DIRECTORY_URL/SUBDIRECTORY</d:href>
<m:node-url>DIRECTORY_URL/SUBDIRECTORY</m:node-url>
<d:propstat>
<d:prop>
<d:creationdate>Mon, 01 Jan 2024 00:00:00 GMT</d:creationdate>
<d:getcontentlength>0</d:getcontentlength>
<d:displayname>Subdirectory name</d:displayname>
<d:getlastmodified>Mon, 01 Jan 2024 00:00:00 GMT</d:getlastmodified>
<d:resourcetype>
<d:collection/>
</d:resourcetype>
<d:quota-available-bytes>5497558015424</d:quota-available-bytes>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>DIRECTORY_URL/FILE</d:href>
<m:node-url>DIRECTORY_URL/FILE</m:node-url>
<d:propstat>
<d:prop>
<d:creationdate>Mon, 01 Jan 2024 00:00:00 GMT</d:creationdate>
<d:getcontentlength>123456</d:getcontentlength>
<d:displayname>File name</d:displayname>
<d:getlastmodified>Mon, 01 Jan 2024 00:00:00 GMT</d:getlastmodified>
<d:resourcetype/>
<d:getetag>54e93f66461535114d8bc6745f66df38</d:getetag>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>
Create a directory
- Parent folder must exist.
curl -X MKCOL 'PARENT_DIRECTORY_URL/DIRECTORY_NAME'
Copy
- Overwrites a target file/directory by default
- Use Overwrite header to prevent overwriting.
Copy a file
curl -X COPY 'SOURCE_FILE_URL' -H 'Destination: TARGET_FILE_URL' -H 'Overwrite: F'
Copy a directory
curl -X COPY 'SOURCE_DIRECTORY_URL' -H 'Destination: TARGET_DIRECTORY_URL' -H 'Overwrite: F'
Copy a directory without its contents
curl -X COPY 'SOURCE_DIRECTORY_URL' -H 'Destination: TARGET_DIRECTORY_URL' -H 'Depth: 0'
Move
- Overwrites a target file/directory by default
- Use Overwrite header to prevent overwriting.
Move a file
curl -X MOVE 'SOURCE_FILE_URL' -H 'Destination: TARGET_FILE_URL' -H 'Overwrite: F'
Move a directory
curl -X MOVE 'SOURCE_DIRECTORY_URL' -H 'Destination: TARGET_DIRECTORY_URL' -H 'Overwrite: F'
Delete
Delete a file
curl -X DELETE 'FILE_URL'
Delete a directory
curl -X DELETE 'DIRECTORY_URL'
Download
Download a whole file
curl -L -o 'some.file' 'FILE_URL'
Chunked download
-
To ensure that the current version of the file is read consistently, the download URL must first be obtained.
curl -i 'FILE_URL'
Response headers:
HTTP/1.1 303 See Other Location: https://... ...
If the redirect is successful, the response contains
Location
header whose value will be used for downloading parts of the file. This URL is used to ensure that this particular version of the file is read. -
Reading individual parts of the file. As an example, the first 500 bytes are downloaded using a Range header and saved to
chunk_file.bin
file.curl -H 'Range: bytes=0-499' -o chunk_file.bin 'URL_FROM_LOCATION_HEADER'
Upload
- You should use
m:node-url
URL as aTARGET_DIRECTORY_URL
.
Upload a whole file
- To preserve the filename, use the URL of the destination directory with a trailing `/` slash.
- To rename the file, append the new file name to the URL of destination directory.
curl -T 'path/to/some.file' 'TARGET_DIRECTORY_URL/'
curl -T 'path/to/some.file' 'TARGET_DIRECTORY_URL/NEW_FILE.NAME'
Chunked upload
- Create an upload in the destination directory.
- Upload all chunks using `X-Upload-Chunk-Url` response header.
- After the last chunk is uploaded, the server automatically creates the target file.
Creating an upload
- Upload name (
X-Upload-Name
) must be unique in the directory. You cannot have 2 concurrent uploads with the same name.
Headers
Header | Value | Description |
---|---|---|
X-Upload-Name* | 1-128 UTF-8 chars | Unique upload name in the destination directory. |
X-File-Name* | 1-128 UTF-8 chars | Target file name. |
X-File-Size* | bytes | File size. |
X-Last-Modified | Unix Timestamp | File last modification date. If not specified, the current date is used. |
cURL example
curl -i -X POST \
-H 'X-Upload-Name: upload-name' \
-H 'X-File-Name: target.filename' \
-H 'X-File-Size: 1000000000' \
-H 'X-Last-Modified: 1234567890' \
'TARGET_DIRECTORY_URL/:chunked-upload'
Response headers:
HTTP/1.1 200 OK
X-Upload-Chunk-Url: https://...
File chunk upload
- Creating a chunked upload returns `X-Upload-Chunk-Url` header. Use this URL to upload all chunks.
- Chunks can be uploaded in parallel.
- It is not necessary to follow the order of the chunks.
- Chunks must not overlap each other.
Headers
Header | Value | Description |
---|---|---|
X-File-Name* | 1-128 UTF-8 chars | Unique upload name in the destination directory. |
X-File-Range* | From-To offset in bytes |
cURL example
curl -X PUT \
-H 'X-Upload-Name: upload-name' \
-H 'X-File-Range: 0-1048576' \
'UPLOAD_CHUNK_URL'
Bulk upload
- Speeds up uploading of small files.
- The size must not exceed 100 MiB.
cURL example
curl -X PUT \
-H 'Content-Type: multipart/form-data; boundary=BbC04y' \
--data-binary '@bulk_upload.txt' \
'TARGET_DIRECTORY_URL/:bulk-upload'
bulk_upload.txt
(CRLF must be used for line breaks):
--BbC04y
Content-Disposition: file; name="file"; filename="file1.txt"
X-File-Size: 123
... file1.txt contents ...
--BbC04y
Content-Disposition: file; name="file"; filename="file2.txt"
X-File-Size: 299
X-Last-Modified: 1234567890
... file2.txt contents ...
--BbC04y--