Javascript 无法从下载文件夹中附加.pdf、.doc、.docs、xlsx、.csv、.ppt、.zip文件

Javascript 无法从下载文件夹中附加.pdf、.doc、.docs、xlsx、.csv、.ppt、.zip文件,javascript,angular,file,ionic-framework,Javascript,Angular,File,Ionic Framework,我正在尝试从我的移动设备(三星)的下载文件夹中附加文件,但执行此操作时使用的checkFile()函数给出错误信息。下面是我的代码: if (self.network.checkInternetConnection()) { // window.FilePath.resolveNativePath('content://...', this.readFile, errorCallback); self.fileChooser.open().then

我正在尝试从我的移动设备(三星)的下载文件夹中附加文件,但执行此操作时使用的checkFile()函数给出错误信息。下面是我的代码:

if (self.network.checkInternetConnection()) {
            // window.FilePath.resolveNativePath('content://...', this.readFile, errorCallback);
            self.fileChooser.open().then((path: any) => {
                console.log(path);
                console.log("fileChooser successCallback");
                (window as any).FilePath.resolveNativePath(path, function (path: any) {
                    let a = path.split('/');
                    let fileName = a.pop();
                    let fileObj = self.fileService.getFileNameExt(fileName);
                    let onlyName = fileObj.onlyName;
                    let ext = fileObj.ext;
                    let p = a.join().replace(/,/g, "/");
                    p = p + "/";
                    console.log(p, fileName);
                    self.file.checkFile(p, fileName)
                        .then(function (suc) {
                            self.file.readAsBinaryString(p, fileName)
                                .then(function (success: any) {
                                    console.log("readAsBinaryString success");
                                    let flag = true;
                                    _.each(self.attachments, function (att: any) {
                                        if (att.docName == onlyName) {
                                            flag = false;
                                            console.log("Attachment already exits");
                                            let toast = self.toastCtrl.create({
                                                message: attErr,
                                                dismissOnPageChange: true,
                                                position: 'bottom',
                                                duration: 5000,
                                            });
                                            toast.onDidDismiss(() => {
                                                console.log('Dismissed toast');
                                            });
                                            toast.present();
                                        }
                                    });
                                   
                                    if (flag) {
                                        self._zone.run(() => {
                                            /*  self.attachments.push({
                                                 docName: onlyName,
                                                 docType: ext,
                                                 document: btoa(success),

                                             }); */
                                             console.log('makeAnnoucement line no. 573 ::',self.calculateImageSize(btoa(success)));
                                            self.fileSize = self.calculateImageSize(btoa(success));
                                            self.attachments.push({
                                                fileName: onlyName,
                                                fileExtension: ext,
                                                data: btoa(success),
                                                fileSize: self.fileSize,
                                            });
                                            self.attachments.forEach(item => {
                                                self.finalSize += item.fileSize;
                                            })
                                        });
                                    }
                                }).catch(function (error) {
                                    console.log("readAsBinaryString fail", error);
                                });
                        }).catch(function (err) {
                            console.log("checkFile false");
                            console.log(err);
                            console.log(JSON.stringify(err));
                        });

                }, self.failureCallback);
            }, this.failureCallback);
        }
fileChooser()也会解析为success,但checkFile()函数会给出“NOT\u FOUND\u ERROR”。我需要在Ionic3应用程序中实现此附件功能,以满足一个需求,但面临上述问题。 如有任何解决此类问题的指导,将不胜感激