如何上传图像保存在存储中,然后在数据库中获取网址

问题描述

我正在将映像上传到Firebase和DB中的存储中,但是存在一个问题

TypeError: _config__WEBPACK_IMPORTED_MODULE_1__.default.firestore is not a function

这是我在API中用于数据的代码,它只有DB尚未存储,如何将两个图像都放入存储并在DB中获得downloadUrl。

const firebaseDb = firebaseApp.database();
const fireStore = firebaseApp.firestore();

/**
 * Representation for creating new product and save to database
 */
export const doCreateProduct = (productData,image_url) => {
  const productId = firebaseDb.ref().push().key;
  return firebaseDb
    .ref(`products/${productId}`)
    .set(productData)
    .then(() => {
      return onceGetProducts();
    })
    .catch((error) => ({
      error,status: "failure",}));
};

这是我的handleImageFile格式

const [imageFile,setimageFile] = useState();

console.log(imageFile);
  const handleFileChange = (event) => {
    console.log("file image",event);
    const image = event.target.files[0]
    setimageFile(imageFile => (image))
  };

  //onSave is a button save after input 
  const onSave = () => {
    createProductRequest(values,imageFile);
  };

这里有人可以帮助我解决这个问题吗?非常感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)