简体   繁体   English

如何从flutter dart中firebasestorage中该文件的链接获取文件名

[英]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.

相关问题 如何使用文件位置链接从保存在 FirebaseStorage 中的 Firebase RealtimeDatabase 下载文件? - How to download a file from Firebase RealtimeDatabase that is saved in the FirebaseStorage using the file location link? 如何在flutter文件中获取一个.dart文件到另一个.dart文件的变量 - How to get a variable of .dart file to another .dart file in flutter 无法使用 Flutter 将文件上传到 FirebaseStorage - Unable to upload File to FirebaseStorage using Flutter 如何使用 MediaStore 将媒体文件从 FirebaseStorage 下载到本地存储? - How to download a media file from FirebaseStorage to local storage using MediaStore? 如何获取 json 文件中的列表,其中包含 flutter dart 中的复杂数据 - how to get a list in a json file with complex data in flutter dart 如何从 FirebaseStorage 获取图像并将其转换为 Bitmap - How to get an image from FirebaseStorage and convert it into a Bitmap 如何从 firebase 存储中的下载链接获取文件名? - How to get file name from download link in firebase storage? 如何从dart文件中的flutter中调用android活动 - how to call android activity from dart file in flutter 在flutter导入dart文件 - Import dart file in flutter 如何从 dart/flutter 中的列表中获取价值? - how to get value from list in dart/flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM