LDWS Storage Endpoints
13 min
get /v1/files/\ path/ lists directories and files in the requested path segment \ path \<font color="#704ae0">string\</font> the path to the directories or files query string parameter raw \<font color="#01a0af">optional\</font> 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 contents \<font color="#01a0af">optional\</font> if a file is specified, this will return the contents of that file 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 downloading a file from player storage to directly download a file from player storage, add ?contents\&stream to the end of the url here is a sample workflow (assuming a base url of http //192 168 0 00/api/v1 ) create a snapshot on the sd card under the remote snapshots using post /v1/snapshot the response will be the name of the snapshot (for example, img 2021 12 29 10 49 27 jpg ) to directly download the snapshot created on the player get http //192 168 0 12/api/v1/files/sd/remote snapshots/img 2021 12 29 10 49 27 jpg?contents\&stream if you enter only ?contents , you get the file in the base64 encoding response body this method returns the metadata for a directory or file (assuming the raw query string parameter is not set) name \<font color="#704ae0">string\</font> name of the directory or file type \<font color="#704ae0">string\</font> either a directory or file path \<font color="#704ae0">string\</font> the path, for example, "sd" mime \<font color="#704ae0">string\</font> mime type (available only for type "file") stat \<font color="#704ae0">object\</font> directory stats from the "fs" module filesize \<font color="#704ae0">int\</font> the size of the filesystem streamable \<font color="#704ae0">bool\</font> this is always true for files if the path is a directory, this is not returned contents \<font color="#704ae0">string\</font> the contents of the specified file 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 } } } response example when returning file contents note that once you have the data string, you will have to decode it (for example, with the atob method in javascript) { "data" { "result" { "mimetype" null, "name" "autorun brs", "contents" "tglicmfyesaiyxv0b3b \<very large data string> " } } post /v1/files/\ path/ renames a file in the path (which should include the file name) segment \ path \<font color="#704ae0">string\</font> the path to a file request body name \<font color="#704ae0">string\</font> 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 "name" "newname txt" response the player will return a \<font color="#15803d">200\</font> success or \<font color="#b91c1c">404\</font> or \<font color="#b91c1c">500\</font> error message success response body { "data" { "result" { "success" true } } } put /v1/files/\ path/ uploads files or creates directories the request body needs to be of type multipart / form data (see rfc 7578 https //datatracker ietf org/doc/html/rfc7578 ) 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 \<font color="#704ae0">string\</font> the path is the folder in which you want to upload the file request body the files as form data, as shown in the example below request example (file) the example request parameters and headers are set as follows path is set to sd put /api/v1/files/sd/ http/1 1 host {{playerip}} authorization {{digestauth}} content length 227 content type multipart/form data; boundary= webkitformboundary7ma4ywxktrzu0gw \ webkitformboundary7ma4ywxktrzu0gw content disposition form data; name="file"; filename="/path/to/file/test txt" content type text/plain (data) \ webkitformboundary7ma4ywxktrzu0gw response body success \<font color="#704ae0">bool\</font> a flag that indicates if the operation succeeded or not results \<font color="#704ae0">string\[]\</font> the names of the files that were successfully created response example (plain text file) { "data" { "result" { "success" true, "results" \[ "test txt" ] } } } request example (folder) put /api/v1/files/sd/testfolder/ host {{playerip}} authorization {{digestauth}} accept application/json, application/vnd bsn error+json response example (folder) { "data" { "result" { "success" true } } } delete /v1/files/\ path/ removes a file or directory segment \ path \<font color="#704ae0">string\</font> 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 delete /api/v1/files/sd/test txt/ http/1 1 host {{playerip}} authorization {{digestauth}} accept application/json response the player will return a \<font color="#15803d">200\</font> success or \<font color="#b91c1c">404\</font> or \<font color="#b91c1c">500\</font> error message success response body { "data" { "result" { "success" true } } } put /v1/storage/encryption/ encrypts the selected media storage note that reformatting the storage device will erase its contents this endpoint is available in bos version 9 0 197 and later request body filepath \<font color="#704ae0">string\</font> \<font color="#01a0af">required\</font> the path to the media storage (for example, “/sd”) settings \<font color="#704ae0">object\</font> type \<font color="#704ae0">string\</font> \<font color="#01a0af">required\</font> the encryption method the options are ‘brightsign key' , 'unique key' , 'password' , and 'none' the options map to devicecustomization storageencryptionoptions docid\ wrjdigxwn 0ynjrujrm3d ( 'brightsign key' is "brightsign key" , 'unique key' is "generate key" , 'password' is "passphrase" 'none' is "none" ) password \<font color="#704ae0">string\</font> \<font color="#01a0af">optional\</font> the password used to encrypt media storage, if any this field is required if settings type is “password“ format \<font color="#704ae0">bool\</font> \<font color="#01a0af">optional\</font> whether or not the storage device should be reformatted by default, the storage will be reformatted doprovision \<font color="#704ae0">bool\</font> \<font color="#01a0af">optional\</font> whether the player should be automatically provisioned with bsn cloud by default, the player will not be automatically provisioned request example the example request parameters and headers are set as follows put /api/v1/storage/encryption/ http/1 1 host {{playerip}} authorization {{digestauth}} accept application/json this is the example request body { "filepath" "/sd", "settings" { "type" "password", "password" "abc", "format" true, "doprovision" true } } success response body and example success \<font color="#704ae0">bool\</font> a flag that indicates if the encryption succeeded or not reboot \<font color="#704ae0">bool\</font> whether or not the player will reboot { "data" { "result" { "success" true, "reboot" false } } } error response body and example error \<font color="#704ae0">string\</font> any error messages associated with the operation { "data" { "error" { "status" 400, "message" "storage is already encrypted please decrypt it first " } } }