簡體   English   中英

Firebase 存儲多個圖像數組 GetDownloadURL 怎么解決?

[英]Firebase Storage multiple image array GetDownloadURL how we can fix it?

我們想通過 GetDownloadUrl 方法獲取我們添加為數組的圖像的鏈接。

我無法將從 GetDownloadUrl 返回的鏈接作為數組添加到 Firestore。

這是代碼:

  const [multipleImage, setImage] = useState([]);
  const [multipleImageFake, setImageFake] = useState([]);

    const task = storegeRef.putFile(uploadUri[i].imgURL).then((url)=>{
           
          });
          setImageFake([{"name":"rest"},{"name":"rest"}]);

這是firestore查詢

 .collection('patients')
      .doc(id)
      .collection('transactions')
      .doc(date)
      .set({
        userId: auth().currentUser.uid,
        postImg: multipleImageFake,
        catchDate: date,
        processDate: firestore.FieldValue.serverTimestamp(),
        diagnosticText: text,
      })

注意:當我使用 putFile 方法時,它給了我 MetaData

確定下載 URL 需要調用服務器,因此是異步操作。 任何需要下載 URL 的代碼,都需要在then()回調中:

我們想通過 GetDownloadUrl 方法獲取我們添加為數組的圖像的鏈接。

我無法將從 GetDownloadUrl 返回的鏈接作為數組添加到 Firestore。

這是代碼:

const [multipleImage, setImage] = useState([]);
const [multipleImageFake, setImageFake] = useState([]);

const task = storegeRef.putFile(uploadUri[i].imgURL).then((url)=>{
  // Here you can access the URL value and for example write it to Firestore           
});

// Here you can't

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM