2017-04-08 82 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 
    } 
    } 
} 
相關問題