/
LDWS Storage Endpoints

LDWS Storage Endpoints

 

GET /v1/files/:path/ 

Lists directories and files in the requested path.

Segment

  • :path string: The path to the directories or files

Query String Parameter

  • raw optional: If the path is for a storage device, this will return its raw contents. For example, the request below would be GET /api/v1/files/sd/?raw

Request Example

The example request parameters and headers are set as follows:

  • :path is set to /sd/autorun.brs/

    GET /api/v1/files/sd/autorun.brs/ HTTP/1.1 Host: {{playerIP}} Authorization: {{DigestAuth}} Accept: application/json

Response Body

This method returns the metadata for a directory or file (assuming the raw query string parameter is not set):

  • name string: Name of the directory or file

  • type string: Either a directory or file

  • path string: The path, for example, "sd"

  • mime string: mime type (available only for type "file")

  • stat object: Directory stats from the "fs" module

  • fileSize int: The size of the filesystem

  • streamable bool: This is always true for files. If the path is a directory, this is not returned

Response Example

{ "data": { "result": { "name": "sd/autorun.brs", "type": "file", "path": "sd/autorun.brs", "mime": "application/octet-stream", "stat": { "dev": 45921, "mode": 33277, "nlink": 1, "uid": 0, "gid": 1003, "rdev": 0, "blksize": 32768, "ino": 40, "size": 1144340, "blocks": 2240, "atimeMs": 1699401600000, "mtimeMs": 1699423824000, "ctimeMs": 1699423824440, "birthtimeMs": 0, "atime": "2023-11-08T00:00:00.000Z", "mtime": "2023-11-08T06:10:24.000Z", "ctime": "2023-11-08T06:10:24.440Z", "birthtime": "1970-01-01T00:00:00.000Z" }, "fileSize": 1144340, "streamable": true } } }

 

POST /v1/files/:path/ 

Renames a file in the path (which should include the file name).

Segment

  • :path string: The path to a file

Request Body

  • name string: The new file name

Request Example

The example request parameters and headers are set as follows:

  • :path is set to /sd/test.txt/

POST /api/v1/files/sd/test.txt/ HTTP/1.1 Host: {{playerIP}} Authorization: {{DigestAuth}} Accept: application/json Content-Type: application/json Content-Length: 21

This is the example request body:

Response

The player will return a 200 success or 404 or 500 error message.

Success Response Body

 

PUT /v1/files/:path/ 

Uploads files or creates directories. The request body needs to be of type multipart/form-data (see RFC 7578). If you add one or more parameters of type file (the name of the parameter does not matter), it will upload the selected file(s). 

To create a directory, remove the form-data from the body, and add the directory as the URL parameter, :path. See the example below.

Segment

  • :path string: The path is the folder in which you want to upload the file.

Request Body

  • files object[]:

    • fileName string: The name of the file

    • fileContents string: The content of the file. It can be provided as plain text or as Data URL.

    • fileType string: Mime type

Request Example (File)

The example request parameters and headers are set as follows:

  • path is set to sd

Response Body

  • success bool: A flag that indicates if the operation succeeded or not

  • results string[]: The names of the files that were successfully created

Response Example (Plain Text File)

Request Example (Folder)

Response Example (Folder)

 

DELETE /v1/files/:path/ 

Removes a file or directory

Segment

  • :path string: The path to the file or directory

Request Example

The example request parameters and headers are set as follows:

  • :path is set to sd/test.txt

Response

The player will return a 200 success or 404 or 500 error message.

Success Response Body

Related content

LDWS General Endpoints
LDWS General Endpoints
More like this
rDWS Files Endpoints
rDWS Files Endpoints
More like this
LDWS Diagnostics Endpoints
LDWS Diagnostics Endpoints
More like this
LDWS Registry Endpoints
LDWS Registry Endpoints
More like this
Local DWS APIs
Local DWS APIs
Read with this
LDWS Remote Snapshot Endpoint
LDWS Remote Snapshot Endpoint
More like this