Reputation: 198
I am using firebase storage to store files in my flutter app i can get the download link of that file from the firebase storage ,but i want the name of that file after uploaded.what is the way to get it. it is an sample link of an .mp3 file generated by firebase storage.
https://firebasestorage.googleapis.com/v0/b/musicapp-002.appspot.com/o/song%20name%2Calbum%20name%2Cartist%20name%20by%20testing0%40gmail.com.mp3?alt=media&token=213b776c-5563-468a-9724-0f53d75aff90
and the file name is song name,album name,artist name by [email protected]
so how to generate the filename from the given firebase storage link.
Upvotes: 0
Views: 1100
Reputation: 4337
Try this :
String link = "https://firebasestorage.googleapis.com/v0/b/musicapp-002.appspot.com/o/song%20name%2Calbum%20name%2Cartist%20name%20by%20testing0%40gmail.com.mp3?alt=media&token=213b776c-5563-468a-9724-0f53d75aff90";
link = link.split("/")[7];
link = link.replaceAll("%20"," ");
link = link.replaceAll("%2C", ",");
link = link.substring(0, link.indexOf('.mp3'));
link = link.replaceAll("%40", "@");
print(link);
Output :
song name,album name,artist name by testing0%40gmail.com
Upvotes: 2