注意:本文档只声明非业务定制的基础 API,原有小程序 API 无法调用。
// 调用
interface ChooseFileParamsType {
count?: number;
accept?: string;
}
const resp = my.chooseFile();
// 返还
// 其中 data 为一个数组,数组中的某一项为文件ID
{
"success": true,
"data": [
"652d9b46-71be-4bc3-b75d-de7ab83e18fb_lADPD3IrulcLja1kYw_99_100.jpg_720x720g.jpg"
],
"ret": [
"SUCCESS::调用成功"
]
}
详细使用文档,请参考上传文件接口。
const uploadResult = await cloud.file.uploadFile({
filePath: `${fileId}`, // fileId 为 chooseFile 返还的文件ID
fileType: 'other',
fileName: '/user/avatar.txt',
});
入参 |
类型 |
是否必填 |
描述 |
apFilePath |
String |
是 |
my.chooseFile 返还的虚拟路径。 |
出参 |
类型 |
描述 |
size |
Number |
选择文件的 fileSize。 |
const fileInfo = await my.getFileInfo({ apFilePath: filePath });
console.log(fileInfo,'fileInfo');
获取缓存数据的异步接口。
const data = await my.getStorage({
key: 'currentCity',
});
将数据存储在本地缓存中指定的 key 中的异步接口。
const data = await my.setStorage({
key: 'currentCity',
data: 999
});
删除缓存数据的异步接口。
const data = await my.removeStorage({
key: 'currentCity',
});
清除本地数据缓存的异步接口。
const data = await my.clearStorage();