第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

盡管更改了數(shù)據(jù)庫規(guī)則,但將文件上傳到 Firebase 存儲仍會返回 403 錯誤

盡管更改了數(shù)據(jù)庫規(guī)則,但將文件上傳到 Firebase 存儲仍會返回 403 錯誤

白板的微信 2022-06-16 15:49:35
我正在創(chuàng)建一個使用 HTML 和 JS 將 gif 上傳到我的 firebase 存儲的基本網(wǎng)頁。這是我的代碼:<!DOCTYPE html><html>    <head>    <meta charset="UTF-8" />    <title>Upload gifs</title>  </head>  <body>    <progress value="0" max="100" id="uploader">0%</progress>    <input type="file" valu="upload" id="fileButton"></input>  </body>    <script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-app.js"></script>    <script src="https://www.gstatic.com/firebasejs/7.7.0/firebase-storage.js"></script>    <script>        var firebaseConfig = {          apiKey: "",          authDomain: "",          databaseURL: "",          projectId: "",          storageBucket: "",          messagingSenderId: "",          appId: "",          measurementId: ""        };    firebase.initializeApp(firebaseConfig);    console.log(firebase);    var uploader = document.getElementById('uploader');    var fileButton = document.getElementById('fileButton');    fileButton.addEventListener('change', function(e){      var file = e.target.files[0];      var storageRef = firebase.storage().ref('gifs/' + "123");      storageRef.put(file);      task.on('state_changed',         function progress(snapshot) {            var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;            uploader.value = percentage;        }        ,        function error(err) {        }      )  })    </script></html>我的 firebase 數(shù)據(jù)庫規(guī)則是:rules_version = '2';service cloud.firestore {  match /databases/{database}/documents {    match /{document=**} {      allow read, write: if true;    }  }}盡管如此,當(dāng)我運行代碼時,它返回一個 403 錯誤,說明它被禁止。我不確定為什么規(guī)則已更改為允許訪問數(shù)據(jù)庫,但我仍然有問題。將不勝感激任何幫助。
查看完整描述

1 回答

?
米琪卡哇伊

TA貢獻1998條經(jīng)驗 獲得超6個贊

您將Cloud Firestore(Firebase 提供的數(shù)據(jù)庫服務(wù)之一)的安全規(guī)則與Cloud Storage的規(guī)則混為一談。


您可以在此處找到 Cloud Storage 安全規(guī)則的文檔:https ://firebase.google.com/docs/storage/security


就您而言,由于從您的問題看來您希望允許任何人讀寫,您將編寫云存儲規(guī)則如下:


service firebase.storage {

  match /b/{bucket}/o {

    match /{allPaths=**} {

      allow read, write;

    }

  }

}


查看完整回答
反對 回復(fù) 2022-06-16
  • 1 回答
  • 0 關(guān)注
  • 115 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號