Diagnostic Web Server APIs
Remote DWS APIs

rDWS Files Endpoints

13min
base url for these endpoints https //ws bsn cloud/rest/v1/ get /files/{\ path}/ lists the directories and/or files in a path segment path string string the path to the directories or files query string parameter raw optional optional returns the raw contents of a directory request example get /rest/v1/files/sd/autorun brs/?destinationtype=player\&destinationname={{deviceserial}} http/1 1 host ws bsn cloud authorization bearer {{useraccesstoken}} accept application/json, application/vnd bsn error+json response body type string string either a directory or file path string string the path, for example, "sd" stat object object directory stats from the "fs" module files object\[ ] object\[ ] name string string name of the file or directory type string string either "file" or "dir" path string string the relative path of the file or directory stat object object file stats from the “fs” module mime string string mime type (available only for type "file") storageinfo object object if the path in the url is a storage device, this returns information about the storage device for more information, see storageinfo docid\ roz3o77euxtyzvj dspin filesystemtype string string the type of filesystem (for example, "fat32") stats object object blocksize int int the size of a native block bytesfree int int the amount of free space filesfree int int the number of used inodes filesused int int the number of free inodes isreadonly bool bool a flag indicating whether the filesystem is read only sizebytes int int the amount of total space mountedon string string the location where the file system is mounted (for example, "/storage/sd") contents object\[ ] object\[ ] name string string the name of the file or directory type string string either "file" or "dir" path string string the absolute path of the file or directory stat object object the statistics from the "fs" module mime string string mime type (available only for type "file") children object\[ ] object\[ ] this is available only for directory types and will have the same format as "contents response example { "route" "/v1/files/sd/autorun brs", "method" "get", "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 } } } put /files/{\ path} uploads a new file or folder to the player storage if you are uploading zip and media files, you should use bos version 8 5 44 or 9 0 101 or later segment path string string the path is the folder in which you want to upload the file (for example "/sd" ) request body files object\[] object\[] filename string string the name of the file filecontents string string the content of the file it can be provided as plain text or as data url filetype string string mime type request example (file) the following request example would be used with one of the two request body examples (plain text or data url) below put /rest/v1/files/sd/?destinationtype=player\&destinationname={{deviceserial}} http/1 1 host ws bsn cloud authorization bearer {{useraccesstoken}} accept application/json, application/vnd bsn error+json content type application/json content length 196 in the request body examples below, use the filereader's readastext() https //developer mozilla org/en us/docs/web/api/filereader/readastext or readasdataurl() https //developer mozilla org/en us/docs/web/api/filereader/readasdataurl method to derive the filecontents value plain text request body any file with mime type "text/ ", or any “brs”, “json”, “js”, “xml”, “rtf” extension, can be sent as plain text using filereader's readastext() https //developer mozilla org/en us/docs/web/api/filereader/readastext method { "data" { "fileuploadpath" "/sd", "files" \[ { "filename" "test txt", "filecontents" "lorem ipsum", "filetype" "text/plain" } ] } } data url request body for all other file types, including zip and media files, use the data url format using filereader's readasdataurl() https //developer mozilla org/en us/docs/web/api/filereader/readasdataurl method { "data" { "fileuploadpath" "/sd", "files" \[ { "filename" "image png", "filecontents" "data\ image/png;base64,dqpjbnrlcmzh ", "filetype" "image/png" } ] } } response body success bool bool a flag that indicates if the operation succeeded or not results string\[] string\[] the names of the files that were successfully created response example (plain text file) { "data" { "result" { "success" true, "results" \[ "test txt" ] } }, "route" "/v1/files/sd", "method" "put" } request example (folder) put /rest/v1/files/sd/testfolder/?destinationtype=player\&destinationname={{deviceserial}} host ws bsn cloud authorization bearer {{useraccesstoken}} accept application/json, application/vnd bsn error+json response example (folder) { "route" "/v1/files/sd/testfolder/", "method" "put", "data" { "result" { "success" true } } } post /files/{\ path}/ renames a file in the path (which should include the file name) segment path string string the path to the file (for example, /sd ) request example post /rest/v1/files/sd/test txt/?destinationtype=player\&destinationname={{deviceserial} http/1 1 host ws bsn cloud authorization bearer {{useraccesstoken}} accept application/json, application/vnd bsn error+json content type application/json content length 57 this is the example request body { "data" { "name" "newname txt" } } response body the player will return a success or error message delete /files/{\ path}/ deletes a file from the player storage segment path string string the path to the file (for example, /sd ) request example delete /rest/v1/files/sd/test txt/?destinationtype=player\&destinationname={{deviceserial}} http/1 1 host ws bsn cloud authorization bearer {{useraccesstoken}} accept application/json, application/vnd bsn error+json response body the player will return a success or error message