EralpB
EralpB

Reputation: 1742

Firebase 3 Storage don't allow file updating/overwriting

Is there a method/ruleset for Firebase 3 storage to disable file updating or overwriting?

I found data.exists() for Database but no solution for Storage.

Upvotes: 6

Views: 2430

Answers (1)

Mike McDonald
Mike McDonald

Reputation: 15963

TL;DR: In Storage Security Rules, request.resource ~= newData.val() and resource ~= data.val(), so you can use them similarly.

service firebase.storage {
  match /b/<bucket>/o {
    match /path/to/file {
      allow write: if resource == null; // if !data.exists() in DB land
    }
  }
}

Upvotes: 14

Related Questions