2017-04-08 52 views

回答

-1

是的。散列图像并使用该名称存储文件。编写一个不允许覆盖文件的规则。

// Upload the file on the client to a file named after a hash of the data 
var string = 'Hello, world!' 
firebase.storage().ref().child('images/' + hash(string)).putString(string); 

var hash = function(string) { /* SHA1, MD5, etc. (note: collisions exist for certain algorithms) */ } 


// Rules 
service firebase.storage { 
    match /b/{bucket}/o { 
    match /images/{imageHash} { 
     // only allow create and delete, not overwrite 
     allow write: if resource == null || request.resource == null 
    } 
    } 
} 
相关问题