Runtime fast game calls copyfile interface to write temporary files and pit records

Problem Description:

Call the copyfile interface to write a temporary file to the cache and an error "no such file or directory" is reported.

problem analysis:

If the source file used to call the copyfile interface is a temporary file, the interface currently does not support this scenario. You need to use the save interface to save the temporary file locally, and then call the copyfile interface.

Solution:

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" );    
                    }})

Original link:https://developer.huawei.com/consumer/cn/forum/topic/0204404942804220219?fid=18

Author: AppGallery Connect

Guess you like

Origin blog.51cto.com/14772288/2571025