提交 c6243f77 编写于 作者: W WOSHIMAHAIFENG

修改file测试示例

上级 086d6d26
...@@ -483,7 +483,7 @@ ...@@ -483,7 +483,7 @@
console.log("success to readdir", res) console.log("success to readdir", res)
res.files.forEach(element => { res.files.forEach(element => {
console.log(element) console.log(element)
let filePath:string let filePath : string
if (this.rmDirFile.length <= 0) { if (this.rmDirFile.length <= 0) {
filePath = `${this.basePath}${element}` filePath = `${this.basePath}${element}`
} else { } else {
...@@ -786,28 +786,36 @@ ...@@ -786,28 +786,36 @@
} }
}, },
unzipFileTest: function (_ : any) { unzipFileTest: function (_ : any) {
const fileManager = uni.getFileSystemManager() uni.downloadFile({
url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip',
fileManager.unzip({ success: (res) => {
zipFilePath: `${this.basePath}${this.unzipFile}`, console.log(res)
targetPath: `${this.basePath}${this.targetZip}`, const fileManager = uni.getFileSystemManager()
success: (res : FileManagerSuccessResult) => { fileManager.unzip({
if (this.logAble) { zipFilePath: res.tempFilePath,
this.log += 'saveFileTest success:' + JSON.stringify(res) + '\n\n' targetPath: `${this.basePath}${this.targetZip}`,
} success: (res : FileManagerSuccessResult) => {
console.log('success', res) if (this.logAble) {
}, this.log += 'unzipFileTest success:' + JSON.stringify(res) + '\n\n'
fail: (res : UniError) => { }
if (this.logAble) { console.log('success', res)
this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n' },
} fail: (res : UniError) => {
console.log('fail', res) if (this.logAble) {
this.lastFailError = res this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (_) => {
this.done = true
}
} as UnzipFileOptions)
}, },
complete: (_) => { fail: (e) => {
this.done = true console.log(e)
} }
} as UnzipFileOptions) })
}, },
getSavedFileListTest: function () { getSavedFileListTest: function () {
...@@ -881,7 +889,7 @@ ...@@ -881,7 +889,7 @@
readCompressedFileTest() { readCompressedFileTest() {
const fileManager = uni.getFileSystemManager() const fileManager = uni.getFileSystemManager()
fileManager.readCompressedFile({ fileManager.readCompressedFile({
filePath: `${this.basePath}${this.brFile}`, filePath: '/static/filemanager/1.txt.br',
compressionAlgorithm: "br", compressionAlgorithm: "br",
success: (res : ReadCompressedFileResult) => { success: (res : ReadCompressedFileResult) => {
if (this.logAble) { if (this.logAble) {
...@@ -906,7 +914,7 @@ ...@@ -906,7 +914,7 @@
const fileManager = uni.getFileSystemManager() const fileManager = uni.getFileSystemManager()
try { try {
let data = fileManager.readCompressedFileSync( let data = fileManager.readCompressedFileSync(
`${this.basePath}${this.brFile}`, '/static/filemanager/1.txt.br',
"br") "br")
if (this.logAble) { if (this.logAble) {
this.log += data this.log += data
...@@ -1224,36 +1232,33 @@ ...@@ -1224,36 +1232,33 @@
} }
}, },
readZipEntry() { readZipEntry() {
const fileManager = uni.getFileSystemManager() uni.downloadFile({
fileManager.readZipEntry({ url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip',
filePath: `${this.basePath}${this.readZipFile}`, success: (res) => {
encoding: 'utf-8', console.log(res)
entries: [{ const fileManager = uni.getFileSystemManager()
path: 'kkkk', fileManager.readZipEntry({
encoding: 'utf-8' filePath: res.tempFilePath,
} as EntryItem, encoding: 'utf-8',
{ success: (res : EntriesResult) => {
path: 'log/log1.txt', if (this.logAble) {
encoding: 'utf-8' this.log += 'readZipEntry success:size=' + res.result.size + '\n\n'
} as EntryItem, }
{ console.log("success", res)
path: 'hello.txt', },
encoding: 'utf-8' fail: (res : UniError) => {
} as EntryItem], if (this.logAble) {
success: (res : EntriesResult) => { this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
if (this.logAble) { }
this.log += 'readZipEntry success:' + JSON.stringify(res) + '\n\n' console.log('fail', res)
} this.lastFailError = res
console.log("success", res) }
} as ReadZipEntryOptions)
}, },
fail: (res : UniError) => { fail: (e) => {
if (this.logAble) { console.log(e)
this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
} }
} as ReadZipEntryOptions) })
}, },
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册