|
|
@ -1,6 +1,13 @@ |
|
|
|
import downloadImg from "./download.js" |
|
|
|
|
|
|
|
/* |
|
|
|
*V1.0 |
|
|
|
*基于5+ IO 封装的基础文件操作库 业务函数 为人脸识别操作提供文件处理功能 |
|
|
|
*使用范围:(7in,8in)Android 11 Pad |
|
|
|
*更新日期:2022/06/09 |
|
|
|
*/ |
|
|
|
|
|
|
|
/* |
|
|
|
fileName: 需要查询的目录名 |
|
|
|
*/ |
|
|
|
async function getFileChildrenList(fileName){ |
|
|
@ -20,6 +27,7 @@ async function getFileChildrenList(fileName){ |
|
|
|
fileName: 需要删除的文件名 |
|
|
|
*/ |
|
|
|
async function deleteAndroidFaceImage(fileName){ |
|
|
|
console.log("deleteAndroidFaceImage:",fileName) |
|
|
|
let item = { |
|
|
|
"deleteFile" : true, |
|
|
|
"name": fileName |
|
|
@ -60,6 +68,9 @@ async function deleteAndroidFaceImage(fileName){ |
|
|
|
*/ |
|
|
|
async function downloadFileList(res){ |
|
|
|
// await asyncSetTimeOut(3000) //延时,手动断网,模拟下载失败
|
|
|
|
let clearUNI = await clearUniDownloadFace(); |
|
|
|
console.log("清空doc结果:",clearUNI) |
|
|
|
|
|
|
|
return new Promise(async(rs,rj)=>{ |
|
|
|
let {list,request_time,total} = res |
|
|
|
console.log(request_time,total); |
|
|
@ -183,7 +194,7 @@ async function downloadFileImg(item) { |
|
|
|
|
|
|
|
} |
|
|
|
let reNamePathEntry = await downloadImg.moveFileTo(savedFilePathEntry, faceSyncEntry, newName); //重命名文件到人脸库同步文件夹
|
|
|
|
// console.log(savedFilePath,newName,reNamePathEntry.fullPath)
|
|
|
|
console.log("重命名后:",savedFilePath,newName,reNamePathEntry.fullPath) |
|
|
|
return reNamePathEntry.fullPath; |
|
|
|
} |
|
|
|
|
|
|
@ -212,6 +223,24 @@ async function clearDownloadFace(fileName){ |
|
|
|
console.log(fileName,"删除:",e); |
|
|
|
}) |
|
|
|
} |
|
|
|
//递归清空本地临时下载目录及子目录
|
|
|
|
async function clearUniDownloadFace(){ |
|
|
|
let fs = await downloadImg.requestFileSystem(plus.io.PRIVATE_DOC); //获取所要操作根目录File System
|
|
|
|
|
|
|
|
// let faceSyncEntry = await downloadImg.getDirectory({
|
|
|
|
// //在PUBLIC_DOWNLOADS下定义人脸库同步文件夹[fileName]
|
|
|
|
// OriginPathEntry: fs.root,
|
|
|
|
// newFileName: fileName
|
|
|
|
// });
|
|
|
|
// let newNameFileEntry = await downloadImg.resolveLocalFileSystemURL(faceSyncEntry.fullPath).catch(
|
|
|
|
// e => {
|
|
|
|
// console.log('操作目标文件', e);
|
|
|
|
// });
|
|
|
|
await downloadImg.removeFileAll(fs).then(e=>{ |
|
|
|
console.log("删除uni _Doc缓存文件:",e); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = { |
|
|
|
downloadFileImg, |
|
|
|
clearDownloadFace, |
|
|
|