Javascript 为什么我要覆盖我的firebase storageRef?

Javascript 为什么我要覆盖我的firebase storageRef?,javascript,firebase,firebase-storage,Javascript,Firebase,Firebase Storage,我有下面的上传功能,我试图上传两个图片到firebase,并将它们的下载URL合并到一个集合中 我的第二个storageRef如何不断覆盖第一个,这只会导致上传压缩图像,并在我的收藏中两次获得压缩图像的链接 我该如何解决这个问题 const onUpload = async () => { if (file) { const options = { maxWidthOrHeight: 250, }; const fullSto

我有下面的上传功能,我试图上传两个图片到firebase,并将它们的下载URL合并到一个集合中

我的第二个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是相同的

file.name和compressedFile.name是相同的

我认为可能导致这种情况的原因之一是如果你有你的文件。name和你的compressedFile.name相同。你检查过吗?我认为可能导致这种情况的原因之一是如果你有你的文件。name和你的压缩文件一样。你检查过了吗?