Runtime快游戲調用copyfile接口寫臨時文件踩坑記錄


問題描述:

調用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

原作者:AppGallery Connect


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM