问题描述
我使用 firebase 控制台将图像上传到 Storage。
见下面的屏幕截图
图像预览未加载错误:加载预览时出错 我在文件位置下找不到下载网址。
任何人都可以帮助丢失的东西吗?我期待某处的下载网址。
规则是默认的:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read,write: if request.auth != null;
}
}
}
谢谢
解决方法
使用 Storage API,您可以尝试检索文件的下载 URL https://firebase.google.com/docs/reference/android/com/google/firebase/storage/StorageReference#getDownloadUrl() 它返回一个 Promise 对象。 例如
const storage = firebase.storage();
const imageRef = storage.ref().child('app-icon-48x48.png'); //if any subfolder include it in the path
imageRef.getDownloadURL().then(function (url) {
console.log(url);
} );