Import resource
1. API Description
This API is used to import resources into media files. The resource files have already been uploaded to the device via Upload resource file.
Request mode:
- V2.6.0 and above: POST [ip]/mwapi/V2.0/source/import-source
- V2.5.0 and below: POST [ip]/mwapi/import-source
Note:
- To import PDF resources, you need to obtain the import process and result through
DEVICE_STATUS_CHANGED_PDF_IMPORTING
in Monitor device status change. - To import web page resources, you need to obtain the import result through
DEVICE_STATUS_CHANGED_IMPORT_WEB_BROWSER
in Monitor device status change.
Administrator Rights | Logged-in |
---|---|
No | Yes |
2. Input Parameters
Name | Required | Type | Description |
---|---|---|---|
sourceType | Yes | Int | Resource type 1: Picture; 2: Video; 6: Music; 7: Note background image; 13: PD; 14: Web page |
fileName | No | String | File name, not required when sourceType is 14. |
md5 | No | String | File MD5 value, not required when sourceType is 14. |
url | No | String | Web page URL, Required only when sourceType is 14. |
3. Output Parameters
Name | Type | Description |
---|---|---|
result | Int | Status code |
message | String | Status description |
info | InfoData | Resource information |
InfoData
Name | Type | Description |
---|---|---|
duration | Int | Resource duration. Only valid for video and music |
filePath | String | Relative path of the resource file, which can be accessed via http://[Device IP]/file/relative_path |
height | Int | Resource height |
id | Int | Resource ID, the unique identity of the resource on the device |
name | String | Resource name |
rotation | Int | Rotation angle, counterclockwise, ranging from 0 to 360 |
thumbnailPath | String | Relative path of the resource thumbnail, which can be accessed via http://[Device IP]/file/relative_path |
type | Int | Resource type 0: Preset resources (capture + pictures + videos); 1: Pictures; 2: Videos; 6: Music; 7: Note background images; 10: GFX images; 11: Scene background images; 12: Scene background color; 13: PDF files; 14: Web pages |
width | Int | Resource width |
4. Example
Importing the image resource "3840x2160.png" into the media file.
Input Example
{
"fileName": "3840x2160.png",
"md5": "a983f73f834efc80bfc21e447352317f",
"sourceType": "1"
}
Output Example
{
"info":{
"duration":0,
"filePath":"2039/2039.png",
"height":1080,
"id":2039,
"name":"IMG_3162",
"rotation":0,
"thumbnailPath":"2039/2039.thumb.jpeg",
"type":1,
"width":1440
},
"message":"success",
"result":0
}
5. Error Code
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Status | Definition | Description |
---|---|---|
7 | MW_STATUS_INVALID_ARG | Missing required parameters |
7 | MW_STATUS_SOURCE_EXIST | The resource already exists. |
9 | MW_STATUS_DECODE_FAIL | File decoding failed (unsupported format). |
29 | MW_STATUS_NO_SPACE | Insufficient disk space. |