diff --git a/atomicserviceweb/interfaces/atomicserviceweb.js b/atomicserviceweb/interfaces/atomicserviceweb.js index 6bf2ff73e9df48e82a36c4c286bdaa229cd530f5..232beecc9ee5de5ee00da75f9a8e8c0b451e9c20 100644 --- a/atomicserviceweb/interfaces/atomicserviceweb.js +++ b/atomicserviceweb/interfaces/atomicserviceweb.js @@ -775,22 +775,6 @@ class AtomicService { return n6.substring(o6 + 1); } - saveDownloadFile(z5, a6, b6, c6) { - let d6 = new filePicker.DocumentViewPicker(); - d6.save({ - newFileNames: [a6] - }).then(h6 => { - let i6 = h6[0]; - fs.copy(fileUri.getUriFromPath(z5), i6).then(() => { - c6 && c6(i6); - }).catch((l6) => { - this.error(l6, b6); - }); - }).catch((g6) => { - this.error(g6, b6); - }); - } - checkAccessToken(v5) { let w5 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); let x5 = w5.appInfo.accessTokenId; @@ -1003,22 +987,14 @@ class AtomicServiceApi extends AtomicService { openPreview(n3) { let o3 = this.getUri(n3.uri); - filePreview.canPreview(this.context, o3).then((s3) => { - if (!s3) { - this.errorWithCodeAndMsg(IMAGE_CAN_NOT_PREVIEW_ERROR, n3); - return; - } - filePreview.openPreview(this.context, { - uri: o3, - mimeType: n3.mimeType, - title: n3.title - }).then(() => { - this.success(new OpenPreviewResult(), n3); - }).catch((v3) => { - this.error(v3, n3); - }); - }).catch((r3) => { - this.error(r3, n3); + filePreview.openPreview(this.context, { + uri: o3, + mimeType: n3.mimeType, + title: n3.title + }).then(() => { + this.success(new OpenPreviewResult(), n3); + }).catch((v3) => { + this.error(v3, n3); }); } @@ -1050,7 +1026,6 @@ class AtomicServiceApi extends AtomicService { } downloadFile(m2) { - let n2 = m2.fileName ? m2.fileName : this.parseFileNameFromUrl(m2.url); let o2 = `${util.generateRandomUUID().replaceAll('-', '')}`; let p2 = `${this.context.cacheDir}/${o2}`; request.downloadFile(this.context, { @@ -1063,9 +1038,7 @@ class AtomicServiceApi extends AtomicService { background: false }).then((t2) => { t2.on('complete', () => { - this.saveDownloadFile(p2, n2, m2, y2 => { - this.success(new DownloadFileResult(y2), m2); - }); + this.success(new DownloadFileResult(p2), m2); }); t2.on('fail', w2 => { this.errorWithCodeAndMsg(new AsError(w2, 'File download fail.'), m2); diff --git a/atomicserviceweb/source/atomicserviceweb.ets b/atomicserviceweb/source/atomicserviceweb.ets index 625fc8603c55f26cdaa37d0ab9bf0ca9722a6357..67faf488adb39044a80dd09729e7b26f997ab500 100644 --- a/atomicserviceweb/source/atomicserviceweb.ets +++ b/atomicserviceweb/source/atomicserviceweb.ets @@ -657,23 +657,6 @@ class AtomicService { return http.substring(index + 1); } - saveDownloadFile(filePath: string, fileName: string, options: DownloadFileOptions, - callback: (uri: string) => void): void { - let documentPicker = new filePicker.DocumentViewPicker(); - documentPicker.save({ - newFileNames: [fileName] - }).then(res => { - let uri: string = res[0]; - fs.copy(fileUri.getUriFromPath(filePath), uri).then(() => { - callback && callback(uri); - }).catch((err: BusinessError) => { - this.error(err, options); - }); - }).catch((err: BusinessError) => { - this.error(err, options); - }); - } - checkAccessToken(permissionName: Permissions): Promise { let bundleInfo: bundleManager.BundleInfo = bundleManager.getBundleInfoForSelfSync( bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION); @@ -889,20 +872,12 @@ class AtomicServiceApi extends AtomicService { openPreview(options: OpenPreviewOptions): void { let uri: string = this.getUri(options.uri as string); - filePreview.canPreview(this.context, uri).then((res: boolean) => { - if (!res) { - this.errorWithCodeAndMsg(IMAGE_CAN_NOT_PREVIEW_ERROR, options); - return; - } - filePreview.openPreview(this.context, { - uri: uri, - mimeType: options.mimeType as string, - title: options.title - }).then(() => { - this.success(new OpenPreviewResult(), options); - }).catch((err: BusinessError) => { - this.error(err, options); - }); + filePreview.openPreview(this.context, { + uri: uri, + mimeType: options.mimeType as string, + title: options.title + }).then(() => { + this.success(new OpenPreviewResult(), options); }).catch((err: BusinessError) => { this.error(err, options); }); @@ -936,7 +911,6 @@ class AtomicServiceApi extends AtomicService { } downloadFile(options: DownloadFileOptions): void { - let fileName: string = options.fileName ? options.fileName : this.parseFileNameFromUrl(options.url); let cacheFileName: string = `${util.generateRandomUUID().replaceAll('-', '')}`; let filePath: string = `${this.context.cacheDir}/${cacheFileName}`; request.downloadFile(this.context, { @@ -949,9 +923,7 @@ class AtomicServiceApi extends AtomicService { background: false }).then((downloadTask: request.DownloadTask) => { downloadTask.on('complete', () => { - this.saveDownloadFile(filePath, fileName, options, uri => { - this.success(new DownloadFileResult(uri), options); - }); + this.success(new DownloadFileResult(filePath), options); }); downloadTask.on('fail', errCode => { this.errorWithCodeAndMsg(new AsError(errCode, 'File download fail.'), options);