Ionic4本机摄像头上传图片错误

时间:2019-12-29 03:51:41

标签: xcode ionic-framework ionic4 ionic-native

我正在尝试使用带有相机插件的离子本机将图片上传到我的Firestorage。上传部分有效,问题在于获取下载网址,我猜xcode阻止了某些内容。我在iOS上收到此错误:

  

2019-12-28 22:42:25.226737-0500 myapp [3490:1332242] [断言]获取断言时出错:{       userInfo = {           RBSAssertionAttribute =;       }   }   2019-12-28 22:42:25.227326-0500 myapp [3490:1332242] [ProcessSuspension] 0x1121d5108-ProcessAssertion()PID 3490无法为PID 3492的过程获取断言   2019-12-28 22:42:25.227421-0500 myapp [3490:1331735] [ProcessSuspension] 0x1121d5108-ProcessAssertion :: processAssertionWasInvalidated()   2019-12-28 22:42:25.228652-0500 myapp [3490:1332242] [断言]获取断言时出错:{       userInfo = {           RBSAssertionAttribute =;       }   }   2019-12-28 22:42:25.228725-0500 myapp [3490:1332242] [ProcessSuspension] 0x1121d5130-ProcessAssertion()PID 3490无法为PID 3490的过程获取断言   2019-12-28 22:42:25.228784-0500 myapp [3490:1331735] [ProcessSuspension] 0x1121d5130-ProcessAssertion :: processAssertionWasInvalidated()   2019-12-28 22:42:25.229707-0500 myapp [3490:1332242] [断言]获取断言时出错:{       userInfo = {           RBSAssertionAttribute =;       }   }   2019-12-28 22:42:25.229770-0500 myapp [3490:1332242] [ProcessSuspension] 0x1121d5158-ProcessAssertion()PID 3490无法为使用PID 3491的过程获取断言   2019-12-28 22:42:25.229885-0500 myapp [3490:1331735] [ProcessSuspension] 0x1121d5158-ProcessAssertion :: processAssertionWasInvalidated()

这是我的方法:

async presentActionSheet() {
    const actionSheet = await this.asCtrl.create({
        header: 'Profile Picture',
        buttons: [{
            text: 'Camera',
            handler: () => {
                const options: CameraOptions = {
                    quality: 60,
                    destinationType: this.camera.DestinationType.DATA_URL,
                    encodingType: this.camera.EncodingType.JPEG,
                    mediaType: this.camera.MediaType.PICTURE,
                    cameraDirection: this.camera.Direction.FRONT,
                    allowEdit: true,
                    correctOrientation: true,
                    targetWidth: 400,
                    targetHeight: 400
                };
                this.camera.getPicture(options)
                    .then( (imageData) => {
                        const img = 'data:image/jpeg;base64,' + imageData;
                        this.profilePreview = this.webview.convertFileSrc(img);
                    } )
                    .catch( (e) => console.error(e) );
            }
        },
        {
            text: 'Cancel',
            role: 'cancel'
        }
        ]
    });
    actionSheet.present();
}

这是save()

async save() {
    const l = await this.loadCtrl.create({
        message: 'Saving'
    });
    l.present();
    let userObj = { ...this.profileForm.value };
    if (this.profilePreview) {
        // tslint:disable-next-line: max-line-length
        this.fbUpload.storage.ref('users/' + this.uid).child('profile')
            .putString(this.profilePreview, 'data_url', {contentType: 'image/jpg'})
            .then(
                async ppData => {
                    ppData.ref.getDownloadURL().then(
                        urlData => {
                            userObj.profilePicture = urlData;
                        }
                    );
                }
            );
    }
    if (this.coverPhotoPreview) {
        // tslint:disable-next-line: max-line-length
        this.fbUpload.storage.ref('users/' + this.uid).child('cover')
            .putString(this.coverPhotoPreview, 'data_url', {contentType: 'image/jpg'})
            .then(
                (ppData) => {
                    ppData.ref.getDownloadURL().then(
                        urlData => {
                            userObj.coverPicture = urlData;
                        }
                    );
                }
            );
    }
    this.userSrv.updateProfile(userObj, this.uid)
        .then( () => {
            alert('Data saved');
        })
        .catch( (e) => alert(e))
        .finally( () => l.dismiss() );
}

0 个答案:

没有答案