嗨,我需要您的帮助。我不断收到此错误
我被困在这里两天了,我真的需要你的帮助。有什么办法可以解决这个问题。
这是我的代码:
var uploader = document.getElementById('uploader');
var fileButton = document.getElementById('fileButton');
//Listen for file
fileButton.addEventListener('change', function(e){
//Get File
var file = e.target.files[0];
// Get current username
var user = firebase.auth().currentUser;
//Create a Storage Ref
var storageRef = firebase.storage().ref(user + '/profilePicture/' + file.name);
//Upload file
var task = storageRef.put(file);
//Update Progress Bar
task.on('state_changed',
function progress(snapshot){
var percentage = (snapshot.bytesTransferred / snapshot.totalBytes) *100;
uploader.value = percentage;
//if percentage = 100
//$(".overlay").hide();
},
function error(err){
},
function complete(){
}
);
});
这是firebase规则:
service firebase.storage {
match /b/talknote-48adf.appspot.com/o {
match /{userId}/profilePicture/{fileName} {
// Anyone can read
allow read;
// Only the user can upload their own profile picture
// Profile picture must be of content-type "image/*"
allow write: if request.auth.uid == userId
&& request.resource.contentType.matches('image/.+');
}
}
}