文件
只能在轻应用中使用,非轻应用网页不能使用。
错误码列表
| 错误码 | 备注 |
|---|---|
| 404 | localId对应本地资源不存在 |
file.upload
调用qt.file.upload,将本地文件上传到服务器。服务器接口支持 POST + multipart/form-data 上传,接收的参数是file。
qt.fileUpload({
url: "https://gips3.baidu.com/it/u=1039279337,1441343044&fm=3028&app=3028&f=JPEG&fmt=auto&q=100&size=f1024_1024",
header: null, // HTTP 请求 Header,不需要则不传
localId: string, // 本地id"
});
参数说明
| 参数 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| url | string | 是 | 文件服务器提供的上传地址 | |
| header | json | 否 | 上次文件的请求头 | |
| localId | string | 是 | 本地id。安卓和鸿蒙规范为"https://resource/文件唯一标识符",iOS规范为"qingtui://resource/文件唯一标识符.文件后缀 |
返回说明
| 参数 | 类型 | 说明 |
|---|---|---|
| data | json | 服务器返回的json对象 |
file.download
调用qt.file.download,将服务器的文件存储在本地,避免重复下载使用。
qt.fileDownload({
url: "https://gips3.baidu.com/it/u=1039279337,1441343044&fm=3028&app=3028&f=JPEG&fmt=auto&q=100&size=f1024_1024",
header: null, // HTTP 请求 Header,如{'content-type': 'image/jpeg'},不需要则不传
localId: string, // 本地id"
});
参数说明
| 参数 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| url | string | 是 | 文件服务器提供的上传地址 | |
| header | json | 否 | 上次文件的请求头 | |
| localId | string | 是 | 本地id。安卓和鸿蒙规范为"https://resource/文件唯一标识符",iOS规范为"qingtui://resource/文件唯一标识符.文件后缀 |
file.remove
调用qt.file.remove删除本地缓存文件
qt.fileRead({
localId: string,
});
file.read
iOS调用qt.file.read读取本地文件,安卓和鸿蒙通过localId直接获取。
qt.file.read({
localId: string,
});
返回说明
| 参数 | 类型 | 说明 |
|---|---|---|
| localId | string | 本地id |
| partCount | int | 分片总数 |
| partNumber | int | 分片编号,从1开始 |
| body | string | 分片的base64字符串 |
iOS客户端是分片回传的,当partCount等于partNumber代表传输结束