如何解决为什么我要覆盖Firebase storageRef?
我具有以下上传功能,试图将两个图像上传到Firebase并将其下载网址合并到一个集合中。
我的第二个StorageRef如何继续覆盖第一个,这导致只上传了压缩图像,并且在我的收藏集中两次获得了压缩图像的链接。
我该如何解决?
const onUpload = async () => {
if (file) {
const options = {
maxWidthOrHeight: 250,};
const fullStorageRef = storage.ref();
const fullFileRef = fullStorageRef.child(file.name);
await fullFileRef.put(file);
const fullUrl = await fullFileRef.getDownloadURL();
const thumbnailStorageRef = storage.ref();
const compressedFile = await imageCompression(file,options);
const compressedFileRef = thumbnailStorageRef.child(compressedFile.name);
await compressedFileRef.put(compressedFile);
const thumbnailUrl = await compressedFileRef.getDownloadURL();
db.collection("images").add({
created: firebase.firestore.FieldValue.serverTimestamp(),full: fullUrl,thumbnail: thumbnailUrl,});
setFile(null);
}
};
解决方法
file.name和compressedFile.name相同
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。