q***@163.com
q***@163.com
  • 发布:2021-11-01 19:02
  • 更新:2021-11-01 19:22
  • 阅读:690

ios里选择的图片或视频存储在临时路径里,怎么把临时路径的文件移动到永久路径里面

分类:HTML5+

目前的需求是,用户选择的图片或者视频存储在本地中,下一次用户需要使用时,直接通过上次存储的绝对路径去拿视频资源,但是ios重启app后,缓存里的图片、视频资源就被清空了,求解怎么能通过临时文件路径把文件移动到永久文件路中,重新打开app后可以通过路径去拿到图片、视频资源。 我试过5+的移动文件,但是在拿到文件移动到父目录上时,找不到父目录,5+提示编码错误

let that = this  
                uni.chooseImage({  
                    sourceType: ['album'],  
                    count: 1,  
                    sizeType: ['original'],  
                    success(res) {  
                        that.virtualImage = plus.io.convertAbsoluteFileSystem(res.tempFilePaths[0])  
                        let timestamp = Date.parse(new Date());  
                        plus.io.resolveLocalFileSystemURL(  
                                res.tempFilePaths[0],  
                                fileEntry => {  
                                    //  获取存储空间根目录  
                                    fileEntry.moveTo('./var/mobile/Containers/Data/Application/4A8DE99B-CEDC-4DAB-8684-0B80E6A7BC9D/Documents/',`/tici${timestamp}.jpg`,function( entry ){  
                                        console.log("Newpath" + entry.fullPath);  
                                        // that.virtualImage = entry.fullPath  
                                                   
                                    }, function ( e ) {  
                                        alert( "Request file system failed: " + e.message );  
                                    });  
                                },  
                                fail => {  
                                    console.error(fail);  
                                }  
                            )
2021-11-01 19:02 负责人:无 分享
已邀请:
q***@163.com

q***@163.com (作者) - 前端开发

用上面代码测试的时候,在移动文件的那里提示 文件没有发现

DCloud_UNI_GSQ

DCloud_UNI_GSQ

https://uniapp.dcloud.io/api/file/file?id=savefile

该问题目前已经被锁定, 无法添加新回复