...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
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: The path to the directories or files
Query String Parameter
raw
optional: Returns the raw contents of a directory
Request Example
Code Block |
---|
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: Either a directory or filepath
string: The path, for example, "sd"stat
object: Directory stats from the "fs" modulefiles
object[ ]:name
string: Name of the file or directorytype
string: Either "file" or "dir"path
string: The relative path of the file or directorystat
object: File stats from the “fs” modulemime
string: mime type (available only for type "file")
storageInfo
object: If the path in the URL is a storage device, this returns information about the storage device. For more information, see storageinfo.fileSystemType
string: The type of filesystem (for example, "fat32")stats
object:blockSize
int: The size of a native blockbytesFree
int: The amount of free spacefilesFree
int: The number of used inodesfilesUsed
int: The number of free inodesisReadOnly
bool: A flag indicating whether the filesystem is read onlysizeBytes
int: The amount of total space
mountedOn
string: The location where the file system is mounted (for example, "/storage/sd")contents
object[ ]:name
string: The name of the file or directorytype
string: Either "file" or "dir"path
string: The absolute path of the file or directorystat
object: The statistics from the "fs" modulemime
string: mime type (available only for type "file")children
object[ ]: This is available only for directory types and will have the same format as "contents
Response Example
...
Code Block | ||
---|---|---|
| ||
{
"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
}
}
} |
...
Endpoints:
...
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: The path is the folder in which you want to upload the file (for example:"/sd"
).
Request Body
files
object[]:fileName
string: The name of the filefileContents
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 following request example would be used with one of the two request body examples (Plain Text or Data URL) below:
Code Block |
---|
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() or 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() method:
Code Block | ||
---|---|---|
| ||
{
"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() method:
Code Block | ||
---|---|---|
| ||
{
"data": {
"fileUploadPath": "/sd",
"files": [
{
"fileName": "image.png",
"fileContents": "data:image/png;base64,DQpJbnRlcmZh.....",
"fileType": "image/png"
}
]
}
} |
Response Body
success
bool: A flag that indicates if the operation succeeded or notresults
string[]: The names of the files that were successfully created
Response Example (Plain Text File)
Code Block | ||
---|---|---|
| ||
{
"data": {
"result": {
"success": true,
"results": [
"test.txt"
]
}
},
"route": "/v1/files/sd",
"method": "PUT"
} |
Request Example (Folder)
Code Block | ||
---|---|---|
| ||
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)
Code Block | ||
---|---|---|
| ||
{
"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: The path to the file (for example,/sd
)
Request Example
Code Block |
---|
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:
Code Block | ||
---|---|---|
| ||
{
"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: The path to the file (for example,/sd
)
Request Example
Code Block |
---|
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.