1
我有这样的代码:离子3 +火力地堡贮存获取简介的图片
/////////////////////////////////////////////CROP + UPLOAD FOR FIREBASE STORAGE//////////////////////////
// Return a promise to catch errors while loading image
getMedia(): Promise<any> {
// Get Image from ionic-native's built in camera plugin
return Camera.getPicture(this.options)
.then((fileUri) => {
// Crop Image, on android this returns something like, '/storage/emulated/0/Android/...'
// Only giving an android example as ionic-native camera has built in cropping ability
if (this.platform.is('ios')) {
return fileUri
} else if (this.platform.is('android')) {
// Modify fileUri format, may not always be necessary
fileUri = 'file://' + fileUri;
/* Using cordova-plugin-crop starts here */
return Crop.crop(fileUri, { quality: 100 });
}
}).then((path) => {
// path looks like 'file:///storage/emulated/0/Android/data/com.foo.bar/cache/1477008080626-cropped.jpg?1477008106566'
// console.log('Cropped Image Path!: ' + path);
path; // return the path of file
window.resolveLocalFileSystemURL(path, FE=>{
FE.file(file=>{
const FR=new FileReader()
FR.onloadend = ((res: any)=>{
let AF=res.target.result
let blob=new Blob([new Uint8Array(AF)], {type: 'image/jpg'});
this.upload(blob)
});
FR.readAsArrayBuffer(file);
})
})
})
}
upload(blob:Blob){
const currentUserId = this.fire.auth.currentUser.uid; // get user UID in firebase
this.Fbref.child(`Profile/${currentUserId}/img`).put(blob); //path in firebase storage
////GET Image URL
this.Fbref.child(`Profile/${currentUserId}/img`).getDownloadURL().then(function(url){
console.log("the URL Image is: " + url);
url;
let photoURL = this.url
});}
它可以正常使用,不会对图像剪切,然后上传....但我不能保存的URL Firestore数据库中用户配置文件DOC内的图像。
需要把为photoURL:(URL图片)
有谁知道怎么办呢?
你好@Juliano JC你对此有回购?上传和显示图像离子3与firebase我遇到一些问题。我会感谢您的反馈。谢谢。 –
你好! ...我现在创建了一个仓库,它位于下面的链接中,我希望它可以帮助你...我还花时间让代码工作..如果有任何疑问,请将它发送到github [https:///github.com/Julianojc/Firebase-Storage-Upload] –
让我看看,非常感谢。 –