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
Parametersfiles
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.