[英]How to get name of a file from the link of that file in firebasestorage in flutter dart
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.我正在使用 firebase 存储在我的 flutter 应用程序中存储文件,我可以从 firebase 存储中获取该文件的下载链接,但我想要上传后该文件的名称。获取它的方法是什么。 it is an sample link of an .mp3 file generated by firebase storage.
它是由 firebase 存储生成的 .mp3 文件的示例链接。
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 testing0@gmail.com
so how to generate the filename from the given firebase storage link.并且文件名是
song name,album name,artist name by testing0@gmail.com
所以如何从给定的firebase存储链接生成文件名。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.