我正在尝试将文件上传到我的存储桶 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
}
}
}
大多数遇到类似问题的人都能够通过将他们的规则更改为我目前的规则来解决这些问题。关于可能导致这种情况的任何想法?