firebase存储错误:404-access\u bucket

anauzrmj  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(325)

我正在尝试将图像上载到firebase存储。当我试图上传图像时,我得到的错误是404,但我已经在firebase中创建了存储。
firebase npm版本: firebase": "^7.24.0 错误:

code: 404
message: "Not Found.  Could not access bucket \"<project>.appspot.com\""
status: "ACCESS_BUCKET"

存储规则:

rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write: if true;
    }
  }
}

firebase初始化:

const app = firebase.initializeApp({
  apiKey: process.env.REACT_APP_FIREBASE_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_DOMAIN,
  projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
  storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.REACT_APP_FIREBASE_SENDER_ID,
  appId: process.env.REACT_APP_FIREBASE_APP_ID,
  measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID
});

export const analytics = app.analytics();
export const storage = firebase.storage();
export default app;

服务js:

export async function uploadImageCloud(image){
    const storageRef = storage.ref("image/" + image.name);
    return storageRef.put(image);
}

上传功能:

function uploadImage(){
        setDataImageUploading(true);
        uploadImageCloud(getDataImage).then((data)=>{
            console.log(data);
            setDataImageUploading(false);
        }).catch((e)=>{
            console.log(e);
            setDataImageUploading(false);
        });
    }

知道我在哪里搞砸了吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题