尽管允许读 + 写,但由于权限错误,Firebase 上传到存储桶失败
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');
});
},
我正在使用元素-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
我能够上传文件。
不确定车把是怎么进去的——我不记得是怎么加的。
我正在尝试将文件上传到我的存储桶 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');
});
},
我正在使用元素-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
我能够上传文件。
不确定车把是怎么进去的——我不记得是怎么加的。