![](/img/trans.png)
[英]Angular Error not allowing me to update and upload images in my Firebase Storage cause of not finding storage bucket
[英]Firebase Upload to Storage Bucket Failing due to Permission Error, despite Allowing Read + Write
我正在嘗試將文件上傳到我的存儲桶ref,但出現錯誤:
r
code
:
"storage/unauthorized"
message
:
"Firebase Storage: User does not have permission to access 'pdf'."
name
:
"FirebaseError"
serverResponse
:
"{↵ "error": {↵ "code": 403,↵ "message": "Permission denied. Could not perform this operation"↵ }↵}"
__proto__
:
Error
這是我用來提交上傳的代碼:
submitUpload: function(){
var files = this.$refs.upload.uploadFiles;
console.log(files);
var storageRef = storage.ref();
var file = files[0]['raw'];
console.log(file + ' is the file');
var fileref = storageRef.child('pdf');
fileref.put(file).then(function(snapshot){
console.log('uploaded');
});
},
我正在使用element-ui上載組件來獲取文件:
<el-upload drag class="upload-demo" ref="upload" :auto-upload="false" v-show="addItem.subcategory!=''">
<el-button slot="trigger" size="small" type="primary" style="margin-bottom: 10px;">select file</el-button>
<el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">upload to server</el-button>
<div class="el-upload__tip" slot="tip">PDFs no larger than 20 mb</div>
</el-upload>
這是我的存儲規則:
service firebase.storage {
match /{bucket}/o {
match /{allPaths=**} {
allow read, write
}
}
}
大多數遇到過類似問題的人都可以通過將他們的規則更改為我當前的問題來解決它們。 關於什么可能導致此的任何想法?
事實證明,{bucket}變量是問題所在。 當我將其替換為應用程序的路徑時,它類似於:
/b/xyz-app.appspot.com/o
我可以上傳文件。
不確定車把如何到達那里-我不記得添加它們了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.