1
votes

I am using firebase and am trying to make the storage publicly accessible. According to the firebase documentation I need to include the following code, which I added to the .js file which contains a function that sends user input to storage.

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

Based off others' problems I've tried:

  • adding ;-s
  • changing it to firebase.storage(code),
  • doing var storage ...

but none of these methods work.

I have my code for configuring firebase (apiKey, authDomain, databaseURL, projectID, and storageBucket) and also initialized the app.

1

1 Answers

0
votes

This isn't code that you would put in a JS file, this is a firebase storage security rule. It is a configuration that you would configure in the console for your project (alternatively, you can deploy the rules via the CLI, but they are still not a direct part of your application code).

You should navigate to the rules tab and input the configuration there:

image from firebase console of the rules setting

Of course, the rule you are suggesting here is very dangerous!

This rule will allow any user (including unauthenticated users!) to write as much as they want into your storage bucket -- effectively giving you the bill for their free storage. You should consider carefully if this is what you really want.