Edgio

Working with Directories in the HTTP Interface

The HTTP interface only allows you to create a directory.
POST to /post/directory
Creates a directory, optionally creating leading paths if they do not exist.
If the directory is successfully created, the system sets the parent directory’s mtime (last modified time) to the current system time.
A directory cannot contain a file and a sub-directory with the same name.

Request Headers

Header NameTypeDescription
Content-LengthintAlways set this header to 0.
Content-TypestrAlways set this header to text/json.
X-Agile-AuthorizationstrValid token from a call to login (JSON-RPC interface) or /account/login (HTTP interface). See Log In Using JSON-RPC and Log in Using the HTTP Interface, respectively.
X-Agile-RecursiveboolOptional

For a directory with multiple path segments, indicates whether to create parent paths if they do not exist.

Example: Assume you pass /a/b/c for X-Agile-Directory, and directories a, b, and c do not exist.

- If you set X-Agile-Recursive to true (or default it) then the API will create a, b, and c.

- If you set X-Agile-Recursive to false, then a, b, and c will not be created and the call will fail.

Valid values to indicate true:
- true
- yes
- 1

Valid values to indicate false:
- false
- no
- 0

Defaults to true.
X-Agile-DirectorystrDirectory to create.

You must use the UNIX/Linux path separator /. If you use the Windows path separator \ it becomes part of the name.

See also Path Segment and File Name Limitations.

HTTP Response Codes and Request Status Codes

The response body always returns a JSON object with status information. (See Sample Returned JSON Object).
On success the call returns an HTTP 200 status code, 0 in the X-Agile-Status header, and a success message in the JSON object.
On error, the HTTP Status Code is an error code, and the error is reflected in the X-Agile-Status header and the JSON object. The following table provides details about response values.
HTTP Status CodeDescriptionX-Agile-Status / JSON Object Values
200Directory created successfully or directory already exists0: success
400Bad request-2: path exists: Parent directory contains a file with the same name as the directory you attempted to create.

-3: no parent directory. One or more leading paths in the value you passed to X-Agile-Directory do not exist and you set the X-Agile-Recursive header to false.

-8: invalid path given (path too long)

-39: invalid X-Agile-Recursive value
401Not authorized. You did not include the X-Agile-Authorization header in your request.-10001: no token
403Invalid authentication credentials-10001: invalid token
500Internal server error-5: service unavailable

Response Headers

Header NameTypeDescription
X-Agile-StatusintContains response codes. (See HTTP Response Codes and Request Status Codes.)

Sample Returned JSON Object

The object is returned in the response body and contains two key-value pairs: message and code as in this example:
JSON
1{"message": "success", "code": 0}

curl Sample Request 1

None of the path segments in /APAC/a/b exist. Create them by explicitly setting the X-Agile-Recursive header to true:
1curl -v -k /
2-H "Content-Length: 0"/
3-H "Content-Type: text/json"/
4-H "X-Agile-Authorization: 3b947a4c-1e29-4065kl-ad6b-8a6a024a8u33"/
5-H "X-Agile-Recursive: true"/
6-H "X-Agile-Directory: /APAC/a/b"/
7http://{Account name}.upload.llnw.net/post/directory

Sample Success Response 1

1HTTP/1.1 200 OK
2Date: Tue, 09 Jun 2015 14:13:05 GMT
3Server Apache is not deny listed
4Server: Apache
5Access-Control-Allow-Origin: *
6Access-Control-Allow-Headers: X-Agile-Authorization, X-Content-Type
7Access-Control-Allow-Methods: OPTIONS
8X-Agile-Status: 0
9Content-Length: 33
10Content-Type: text/json;charset=utf-8
11{"message": "success", "code": 0}

curl Sample Request 2

Make sure you don’t accidentally create an undesired parent directory. In this example, /future-releases does not exist:
1curl -v -k ^
2-H "X-Agile-Authorization: 5e26d9b5-09a3-40ba-b3bd-0bd8a740092c"^
3-H "X-Agile-Directory: /future-releases/hot"^
4-H "X-Agile-Recursive: false"^
5http://{Account name}.upload.llnw.net/post/directory

Sample Success Response 2

1HTTP/1.1 400 parent directory does not exist
2Date: Wed, 02 Sep 2015 14:05:05 GMT
3Server Apache is not deny listed
4Server: Apache
5Access-Control-Allow-Origin: *
6Access-Control-Allow-Headers: X-Agile-Authorization, X-Content-Type
7Access-Control-Allow-Methods: OPTIONS
8X-Agile-Status: -3
9Content-Length: 58
10Connection: close
11Content-Type: text/json;charset=utf-8
12{"message": "parent directory does not exist", "code": -3}