问题
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