FileSystemManager.saveFileSync(string tempFilePath, string filePath)
功能描述
FileSystemManager.saveFile的同步版本。
参数
string tempFilePath
临时存储文件路径 (本地路径)
string filePath
要存储的文件路径 (本地路径)
返回值
string savedFilePath
存储后的文件路径 (本地路径)
示例代码
const fs = mgtv.getFileSystemManager()
// 选择图片后,保存到文件系统
mgtv.chooseImage({
count: 1,
sourceType: ['album'],
sizeType: ['compressed', 'original'],
success: (res) => {
const [path] = res.tempFilePaths
// 同步接口
try {
fs.saveFileSync(path, `${mgtv.env.USER_DATA_PATH}/1.png`)
mgtv.showToast({
title: '文件保存成功'
})
} catch(e) {
console.error(e)
}
}
})