javascript - Firebase 上传未获取下载 URL
问题描述
我正在开发一个功能,我将从模拟器上传图像并发送到 Firebase 存储。我想获取 downloadURL 并将其放入 firebase firestore,但是我没有检索下载 URL。将不胜感激帮助..谢谢!我目前正在使用firebase存储和firestore,ionic v5进行我的项目。
uploadToStorage(){
let options: CameraOptions ={
quality : 100,
destinationType:this.camera.DestinationType.DATA_URL,
encodingType : this.camera.EncodingType.JPEG,
sourceType : this.camera.PictureSourceType.PHOTOLIBRARY
}
this.camera.getPicture(options).then((data)=>{
var storage = this.store.ref('/AAA');
var photoRef = storage.child(this.mAuth.auth.currentUser.uid);
let base64img = 'data:image/jpeg;base64' + data;
var message = data;
photoRef.putString(message , 'base64', { contentType: 'image/jpg' }).then((savedPicture) => {
savedPicture.downloadURL().subscribe((datas)=>{
console.log(datas)
})
});
});
}
解决方案
savedPicture.snapshot.ref.downloadURL().then((datas)=>{
console.log(datas)
})
https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress
推荐阅读
- c# - Entity Framework Core - 一个模型用于多个查询
- javascript - 为什么 var result = typeof - "Hello, World"; 返回一个数字而不是异常?
- r - 如何聚合和绘制数据框的数据
- azure-application-insights - 来自 App Insights BLOB 的流分析无法运行:GetArrayElement“不支持表达式”
- javascript - 如何使用Django将表中的数据保存到数据库?
- javascript - 什么是分块[chunked.length - 1]?在这段代码中
- r - 我不能在闪亮中使用汇总(平均函数)来绘制条形图
- regex - 如何从 python 字符串中提取数字?
- intellij-idea - Rider 在上下文弹出窗口中未显示“检查表达式是否为空”
- git - GitHub - 如何将提交链接到我的帐户?