0
我正在製作Ionic應用程序,我希望用戶選擇圖像,剪切並上載圖像。爲此,我使用了cordova camera plugin和cordova crop plugin。這是我的文件選擇器代碼:將圖像上傳到Firebase存儲時出錯
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
});
}
然後我上傳創建到火力存儲斑:
[...]
const imageRef = storageRef.child(`profilePics/photo.jpg`).put(this.blobimg);
它說,它是成功的,但上傳的圖片只有105 B和爲所有黑色(也就是說,它不是一個真正的圖像)。
我在這裏做錯了什麼?