如何从 firebase 中的上传字节获取数据 URL?
how to get data URL from upload bytes in firesbase?
如何在上传到firebase存储后从快照中获取数据URL,我在快照中找不到link,必须有另一种方法来完成操作。
if (input?.files![0]) {
const storage = getStorage();
const storageRef = ref(storage, `profiles/${_authContext.currentUser.uid}/${input?.files![0].name}`);
// 'file' comes from the Blob or File API
uploadBytes(storageRef, input?.files![0]).then((snapshot) => {
console.log(snapshot);
console.log('Uploaded a blob or file!');
});
}
你还有一件事要做。它包含在 documentation. Use getDownloadUrl().
中
getDownloadURL(ref(storage, 'images/stars.jpg'))
.then((url) => {
// `url` is the download URL for 'images/stars.jpg'
}
您只能在上传完全完成后执行此操作。
如何在上传到firebase存储后从快照中获取数据URL,我在快照中找不到link,必须有另一种方法来完成操作。
if (input?.files![0]) {
const storage = getStorage();
const storageRef = ref(storage, `profiles/${_authContext.currentUser.uid}/${input?.files![0].name}`);
// 'file' comes from the Blob or File API
uploadBytes(storageRef, input?.files![0]).then((snapshot) => {
console.log(snapshot);
console.log('Uploaded a blob or file!');
});
}
你还有一件事要做。它包含在 documentation. Use getDownloadUrl().
中getDownloadURL(ref(storage, 'images/stars.jpg'))
.then((url) => {
// `url` is the download URL for 'images/stars.jpg'
}
您只能在上传完全完成后执行此操作。