首页 > 解决方案 > 将图像数组上传到 Firebase 存储并返回其 url React Native

问题描述

我正在将图像上传到 firebase 存储,我对此没有任何问题,但是我拥有的引用将图像的名称返回到一个名为 imagesBlob 的数组中。我想在上传后返回每张图片的下载 URL 并将其放入该 imagesBlob 数组中。

我怎样才能做到这一点??

这是我的功能:

    const uploadImagesStorage = async (imageArray) => {
        const imagesBlob = [];

        await Promise.all(
            imageArray.map(async (image) => {
                const response = await fetch(image);
                const blob = await response.blob();
                const ref = firebase
                    .storage()
                    .ref('provider-images')
                    .child(uuidv4());
                await ref.put(blob).then((result) => {
                    imagesBlob.push(result.metadata.name);
                });
            }),
        );

        getImageUrls(imagesBlob);
    };

标签: javascriptfirebasereact-nativereact-hooksfirebase-storage

解决方案


推荐阅读