以 Promise 风格 调用:不支持
保存临时文件到本地。此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用。
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
tempFilePath | string | 是 | 临时存储文件路径 (本地路径) | |
filePath | string | 否 | 要存储的文件路径 (本地路径) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
---|---|---|
savedFilePath | string | 存储后的文件路径 (本地路径) |
function saveFile(tempFilePath, filePath = '') { xhs.saveFile({ tempFilePath, // 临时存储文件路径 filePath, // 可选:要存储的文件路径 success: (res) => { console.log('文件保存成功:', res.savedFilePath); // 存储后的文件路径 }, fail: (err) => { console.error('文件保存失败:', err); }, complete: () => { console.log('文件保存操作完成'); } }); } // 调用示例 saveFile('/path/to/temp/file.txt');