问题描述:

调用copyfile接口将临时文件写入到缓存报错“no such file or directory”。

问题分析:

如果调用copyfile接口使用的源文件是临时文件,则该接口目前不支持此场景,需要使用save接口先将临时文件保存到本地,然后再调用copyfile接口。

解决方法:

var fileSystemManager = hbs.getFileSystemManager();
fileSystemManager.saveFile({
    tempFilePath: ‘temp file path’,
        filePath: ‘target file path’,
            success : function(res) {
                    console.log("saveFile success res = " + JSON.stringify(res));    
                    },    
                    fail : function(data) {        
                    console.log("saveFile fail " + JSON.stringify(data));    
                    },    
                    complete : function() {        
                    console.log("saveFile complete" );    
                    }}) 
                    fileSystemManager.copyFile({    
                    srcPath : ‘source file’,  //源文件路径,只可以是本地文件    
                    destPath : ‘target path’,    
                    success : function() {        
                    console.log("copy success" );    
                    },    
                    fail : function(data) {        
                    console.log("copy fail " + JSON.stringify(data));    
                    },    
                    complete : function() {        
                    console.log("copy complete" );    
                    }})

原文链接:
https://developer.huawei.com/consumer/cn/forum/topic/0204404942804220219?fid=18
作者:Mayism

相关文章:

  • 2021-07-04
  • 2021-12-07
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-09-14
  • 2021-12-04
  • 2021-06-20
猜你喜欢
  • 2022-02-22
  • 2021-06-22
  • 2022-12-23
  • 2021-08-31
  • 2021-10-18
  • 2021-07-07
相关资源
相似解决方案