FileSystemManager.saveFileSync
解释:保存临时文件到本地的同步接口。此接口会移动临时文件,因此调用成功后, tempFilePath 将不可用。
方法参数:String tempFilePath, String filePath
:临时存储文件路径。:要存储的文件路径。
同步返回参数说明:
Error对象
代码示例
-
Page({ onLoad() { const fs = swan.getFileSystemManager(); this.fs = fs; }, saveFileSync() { try { let result = this.fs.saveFileSync( '/usr/temp.txt', // 仅为示例,实际上请传真实临时路径地址,如 swan.downloadFile 的 tempFilePath 返回参数 `${swan.env.USER_DATA_PATH}/` ); console.log('saveFileSync success', result); } catch (err) { console.log('saveFileSync fail', err); } }});
