Is there a way to overwrite a saved file in firebase storage?

偶尔善良 提交于 2020-06-15 23:48:13

问题


I am dealing with profile pictures in my ionic 1 App. I am searching for a way to update a file in firebase storage such that the download link remains the same. Is it possible or any other way to achieve the required?


回答1:


You can't update the file and maintain the same public download link--it's a different file, so it's assumed that you might want to change the access permissions

Just re-fetch the URL and download the file once it's been updated (it's actually returned in the metadata returned on upload, so you can send it to other apps right after you change it, no need to grab the URL separately):

var file = ... // use the Blob or File API
ref.put(file).then(function(snapshot) {
  var url = snapshot.downloadURL;
});



回答2:


As the other answer says, basically you cant update the image without it changing the permissions.

BUT, if you change your rules for the path where your image is stored to say

allow read: if true;
allow write: if request.auth != null;

this basically makes it where anyone with the link can see the image. This will let you see the new image from the old download link.

But just know that this also means anybody with this link can see the image, not just people from your app.



来源:https://stackoverflow.com/questions/41423890/is-there-a-way-to-overwrite-a-saved-file-in-firebase-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!