/files/create

Create directories, files, and symbolic links on the node. To create files, directories, or symbolic links by using bearer token authentication, use the /files endpoint.

Requirements
  • Available as of Enterprise Server version 3.0.0.
  • On Unix-like OSes, if you want to allow /files/create to set the owner of the created files and directories, run the following command:
    # asconfigurator -x "set_node_data;group_ownership,-"
    Otherwise, when a group ID is set on a parent directory, files and directories and that are created in the parent directory by using /files/create have the primary group ID of the user rather than the group ID of the parent directory.
Access Control
  • HTTP Basic Auth
    Users who authenticate with Node API credentials can create items in paths that are within their docroot. Access key users can create items in paths that are within the path set in the access key.
URL
POST https://{domain}:9092/files/create

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/create \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [
        {
            "path": "new_directory_pathname",
            "type" : "directory"
        },
        {
            "path": "new_file_pathname",
            "type" : "file"
        },
        {
            "path": "new_symlink_pathname",
            "type" : "symbolic_link",
            "target" : {
                "path" : "target_pathname"
        }
}

Headers

All requests to this endpoint use the same headers.

Header Name Required Description Values
Content-Type Optional The format of the request data. application/json
Accept Optional The format of the response data. application/json
Request Body
Element Required Type Description
paths Required JSON Array containing the paths of the files, directories, and symbolic links to create.
path Required String The pathname for the new item.
type Required String The type of item to create. Values are file, directory, or symbolic_link.
target Required if type is symbolic_link JSON JSON containing the target pathname.
Sample Response
HTTP/1.1 200 OK
Cache: no-cache
Connection: close
Content-Type: application/json; charset=utf-8

{
    "paths" : [
        {
            "path" : "/Users/aspera/Documents/file1.txt"
        },
        {
            "path" : "/Users/aspera/Documents/symlink1",
            "error" : {
                "code" : 409,
                "reason" : "Conflict",
                "user_message" : "Path already exists"
        }
    ]
}

Status Codes and Errors
Code Description Notes
200 OK Success
400 Bad Request Error Request contains a formatting or syntax error.
404 Not Found Error Invalid pathname.
409 Conflict Error Path already exists.
500 Internal Server Error Error The server configuration is invalid.
Response
Element Type Description
paths JSON JSON object that lists the pathnames created by the request.
path String The new item pathname.
error JSON JSON object describing an error.
code Unsigned integer HTTP error code number.
reason String Short error description.
user_message String Longer error description.
Video player

Video

×