首頁>技術>

作者|Mayism|華為開發者論壇

問題描述:

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

8
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 讀評《web全棧工程師的自我修養》