问题描述:
调用copyfile接口将临时文件写入到缓存报错“no such file or directory”。
问题分析:
如果调用copyfile接口使用的源文件是临时文件,则该接口目前不支持此场景,需要使用save接口先将临时文件保存到本地,然后再调用copyfile接口。
解决方法:
1var fileSystemManager = hbs.getFileSystemManager(); 2fileSystemManager.saveFile({ 3 tempFilePath: ‘temp file path’, 4 filePath: ‘target file path’, 5 success : function(res) { 6 console.log("saveFile success res = " + JSON.stringify(res)); 7 }, 8 fail : function(data) { 9 console.log("saveFile fail " + JSON.stringify(data)); 10 }, 11 complete : function() { 12 console.log("saveFile complete" ); 13 }}) 14 fileSystemManager.copyFile({ 15 srcPath : ‘source file’, //源文件路径,只可以是本地文件 16 destPath : ‘target path’, 17 success : function() { 18 console.log("copy success" ); 19 }, 20 fail : function(data) { 21 console.log("copy fail " + JSON.stringify(data)); 22 }, 23 complete : function() { 24 console.log("copy complete" ); 25 }})
原文链接: https://developer.huawei.com/consumer/cn/forum/topic/0204404942804220219?fid=18 作者:Mayism