我正在尝试使用类似离子的方式从画廊中将.mp3文件上传到Firebase:
var optionsVideo: CameraOptions = {
quality: 70,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.camera.DestinationType.DATA_URL,
mediaType: this.camera.MediaType.ALLMEDIA
}
this.camera.getPicture(optionsVideo).then((audio) => {
var segments = audio.split("/");
var lastSeg = segments[segments.length - 1];
segments = lastSeg.split(".");
var format = segments[segments.length - 1];
if(format == 'mp3' || format == 'wav' || format == 'aiff'){
alert(audio);
var blob = new Blob([audio], {type: 'audio/' + format});
var archivo = {obj: blob, type: 'audio/' + format}
this.archivo = archivo;
this.subirArchivo();
}else{
this._defaultService.mostrar_toast(this.strAudio, 2000);
}
}, (err) => {
alert(JSON.stringify(err));
});
let uploadTask: firebase.storage.UploadTask = storeRef.child(`${ ruta }/${ id }/${ nombreArchivo }`).put(upload, {contentType: 'audio/mp3'});
该文件已正确上传,但其重量比必须称重的少得多,并且无法复制。也许问题出在Blob