filesystemmanager.savefilesync(string tempfilepath, string filepath)
基础库 2.7.4 或更高版本; 若版本较低,建议采取 兼容处理 。
支小宝客户端 支持
安诊儿客户端 支持
主体: 企业支付宝小程序 、 个人支付宝小程序
相关文档: filesystemmanager.savefile 、 本地临时文件 、 本地缓存文件 、 本地用户文件
string tempfilepath
必填
要保存的 本地临时文件 路径。
string filepath
非必填
指定保存后的 本地用户文件 路径;
若不指定,则保存为 本地缓存文件。
object
属性 | 类型 | 描述 |
---|---|---|
savedfilepath | string | 存储后的文件路径。 |
接口调用出错时,返回 object 对象,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
10022 | 指定文件不存在。 |
检查临时文件是否存在 |
10024 | 指定的路径没有写的权限。 |
检查是否有权限写入,参考入参描述。 |
10028 | 单个文件大小超出上限 10mb / 超出最大存储量 50mb。 | 支付宝客户端 10.3.80 以下版本会报此错,请提示用户更新支付宝客户端。 |
文件夹超过 200m |
filesystemmanager.savefilesync(string tempfilepath, string filepath)
下载后保存为本地用户文件
const fs = my.getfilesystemmanager();
const result = fs.savefilesync(
'xxx',
// 默认保存为本地缓存文件
);
console.log(result);
const fs = my.getfilesystemmanager();
my.downloadfile({
url: 'https://img.alicdn.com/tfs/tb1x669sxxxxxbdafxxxxxxxxxx-520-280.jpg', // 下载文件地址,仅供参考
success: res => {
const result = fs.savefilesync(
res.apfilepath,
`${my.env.user_data_path}/example.jpg` // 保存为本地用户文件。此参数不传则保存为本地缓存文件
);
console.log(result);
},
});