Methods for Working with File Server Resources

To work with file server resources, execute requests using the "file" and "directory" API methods (determine user token before executing the request).

In requests for working with a local data storage, use local_storage instead of the <connection name> substitution.

NOTE. Requests to file server resources are available only if there is a configured connection to the file server folder.

Requests and examples of responses:

curl '<IP address or DNS server name>/api/v1/file/<connection name>/?file=<relative path to file on file server>/<file name>' -H "Authorization: bearer <user token>"

The example of response:

{
  "code": 403,
  "description": "The user does not have permissions to execute this operation",
  "original_descriptions": []
}

curl -X PUT '<IP address or DNS server name>/api/v1/file/<connection name>/?file=<relative path to file on file server>/<name of loaded file>' -H "Authorization: bearer <user token>" --upload-file <relative path of loaded file> -H 'Content-Disposition: inline; filename="<name of loaded file>"'

The example of response:

204 File loaded successfully.

curl -X DELETE '<IP address or DNS server name>/api/v1/file/<connection name>/?file=<relative path to file on file server>/<file name>' -H "Authorization: bearer <user token>"

The example of response:

{
  "code": 404,
  "description": "No found",
  "original_description": []
}

curl '<IP address or DNS server name>/api/v1/file/<connection name>/meta/?file=<relative path to file on file server>/<file name>' -H "Authorization: bearer <user token>"

The example of response:

{
 "stat": {
   "st_mode": 33188,
   "st_ino": 7502955,
   "st_dev": 2052,
   "st_nlink": 1,
   "st_uid": 1000,
   "st_gid": 1000,
   "st_size": 13181,
   "st_atime_ns": 1527775186741983500,
   "st_mtime_ns": 1527775066929988000,
   "st_ctime_ns": 1527775066929988000,
   "st_blocks": 32,
   "st_blksize": 4096,
   "st_rdev": 0
 }
}

NOTE. If a file information request is sent to a local data storage or file systems S3, the response will contain some empty parameter values because of architecture features.

Table of returned parameters

curl '<IP address or DNS server name>/api/v1/directory/<connection name>/?directory=<relative path to requested directory>' -H "Authorization: bearer <user token>"

The example in the JSON format:

{
    "type": "directory",
    "name": "sasha_test-reg3",
    "children": [
        {
            "type": "directory",
            "name": "dir1",
            "children": [
                {
                    "type": "directory",
                    "name": "dir1.1",
                    "children": [
                        {
                            "type": "file",
                            "name": "dok2.txt"
                        }
                    ]
                },
                {
                    "type": "directory",
                    "name": "dir1.2",
                    "children": []
                }
            ]
        },
        {
            "type": "directory",
            "name": "dir2",
            "children": []
        },
        {
            "type": "file",
            "name": "dok1.txt"
        }
    ]
}

curl '<IP address or DNS server name>/api/v1/directory/<connection name>/?directory=<relative path to requested directory>&depth=<nesting depth level>' -H "Authorization: bearer <user token>"

The example of response with the first nesting depth level in the JSON format:

{
    "type": "directory",
    "name": "sasha_test-reg3",
    "children": [
        {
            "type": "directory",
            "name": "dir1"
        },
        {
            "type": "directory",
            "name": "dir2"
        },
        {
            "type": "file",
            "name": "dok1.txt"
        }
    ]
}

curl -X PUT '<IP address or DNS server name>/api/v1/directory/<connection name>/?directory=<relative path to created directory>' -H "Authorization: bearer <user token>"

When the directory is successfully created, the response is empty and with the 204 status.

curl -X DELETE '<IP address or DNS server name>/api/v1/directory/<connection name>/?directory=<relative path to deleted directory>' -H "Authorization: bearer <user token>"

When the directory is successfully deleted, the response is empty and with the 204 status.

See also:

Server API | Connecting to File Servers