【发布时间】:2018-01-12 18:53:42
【问题描述】:
我正在使用 Ionic 制作一个应用程序,我希望用户在其中选择图像,裁剪并上传。为此,我使用cordova camera plugin 和cordova crop plugin。这是我的文件选择器代码:
OpenFilePicker() {
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: 0 //0 = Chose File; 1 = Take picture
}
this.camera.getPicture(options).then((imageData) => {
//Using the crop plugin:
this.crop.crop(imageData, {quality: 75})
.then((newPath) => {
//Creating the blob
this.blobimg = new Blob([newPath], {type : 'image/jpeg'});
})
.catch((err) => {
// Handle error crop plugin
})
}, (err) => {
// Handle error camera plugin
});
}
然后我将创建的 blob 上传到 firebase 存储:
[...]
const imageRef = storageRef.child(`profilePics/photo.jpg`).put(this.blobimg);
说成功了,但是上传的图片只有105B,全黑(也就是说,它不是真正的图片)。
我在这里做错了什么?
【问题讨论】:
标签: firebase ionic-framework firebase-storage ionic3