rDWS Storage Endpoints
9 min
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 \<font color="#704ae0">string\</font> the path to the directories or files query string parameter raw \<font color="#01a0af">optional\</font> returns the raw contents of a directory contents \<font color="#01a0af">optional\</font> if a file is specified, this will return the contents of that file 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 \<font color="#704ae0">string\</font> either a directory or file path \<font color="#704ae0">string\</font> the path, for example, "sd" stat \<font color="#704ae0">object\</font> directory stats from the "fs" module files \<font color="#704ae0">object\[ ]\</font> name \<font color="#704ae0">string\</font> name of the file or directory type \<font color="#704ae0">string\</font> either "file" or "dir" path \<font color="#704ae0">string\</font> the relative path of the file or directory stat \<font color="#704ae0">object\</font> file stats from the “fs” module mime \<font color="#704ae0">string\</font> mime type (available only for type "file") storageinfo \<font color="#704ae0">object\</font> 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 \<font color="#704ae0">string\</font> the type of filesystem (for example, "fat32") stats \<font color="#704ae0">object\</font> blocksize \<font color="#704ae0">int\</font> the size of a native block bytesfree \<font color="#704ae0">int\</font> the amount of free space filesfree \<font color="#704ae0">int\</font> the number of used inodes filesused \<font color="#704ae0">int\</font> the number of free inodes isreadonly \<font color="#704ae0">bool\</font> a flag indicating whether the filesystem is read only sizebytes \<font color="#704ae0">int\</font> the amount of total space mountedon \<font color="#704ae0">string\</font> the location where the file system is mounted (for example, "/storage/sd") contents \<font color="#704ae0">object\[ ]\</font> name \<font color="#704ae0">string\</font> the name of the file or directory type \<font color="#704ae0">string\</font> either "file" or "dir" path \<font color="#704ae0">string\</font> the absolute path of the file or directory stat \<font color="#704ae0">object\</font> the statistics from the "fs" module mime \<font color="#704ae0">string\</font> mime type (available only for type "file") children \<font color="#704ae0">object\[ ]\</font> this is available only for directory types and will have the same format as "contents response body if returning contents name \<font color="#704ae0">string\</font> the name of the file mimetype \<font color="#704ae0">string\</font> mime type of the file contents \<font color="#704ae0">string\</font> the contents of the file response examples { "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 } } } if you passed in a contents query paramter in your request, you should expect a response like the one below note that once you have the data string, you will have to decode it (for example, with the atob method in javascript) { "route" "/v1/files/sd/autorun brs", "method" "get", "data" { "result" { "mimetype" null, "name" "autorun brs", "contents" "tglicmfyesaiyxv0b3b \<very large data string> " } } } 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 \<font color="#704ae0">string\</font> the path is the folder in which you want to upload the file (for example "/sd" ) request body files \<font color="#704ae0">object\[]\</font> filename \<font color="#704ae0">string\</font> the name of the file filecontents \<font color="#704ae0">string\</font> the content of the file it can be provided as plain text or as data url filetype \<font color="#704ae0">string\</font> 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 \<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" ] } }, "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 \<font color="#704ae0">string\</font> 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 \<font color="#704ae0">string\</font> 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