Finding file from name


TL/DR I want to find the link of a local file I uploaded on another page using just the file name.

I am currently making an app where you can upload a list of songs in the media_screen, you can then create a player on another screen and attach a certain song to that player and then play the song from that screen. I used firebase and cloudinary to do all of that and it works perfectly. However I didn’t want this app to entirely online only, so I created a switch in the settings screen that can toggle offline mode, this essentially will just make it so the list of media on the media screen is set from the local storage variable instead of from cloudbase however I can’t seem to figure something out.

Currently when you hit the + button it launches the file picker and saves the name of the file to the offlineSongList variable and I created another variable that does the same thing with the file. However I can’t seem to find a way to get the file associated with the file name later on, for example lets say I upload 3 files, music1.mp3, music2.mp3, and music3.mp3. Each of these files have a unique link to the file on the device. Lets say I want to create a new player called Player1 and assign them with music2.mp3, that works just fine, it will display the name of the file however I don’t know how to fetch the link to the file location. Currently the offlineSongFileList variable does nothing, I was just experimenting with it.

The green file block will contain the url of the file that was uploaded to the device.

Is it not working to retrieve that value from the list variable you used?

No it works fine I was just a little confused on what logic I would need to use to fetch the correct file using the name. I ended up assigning each file a unique id based on its index in the list. Since everytime a file name is uploaded a file link is uploaded at the same time. Meaning if I want the file for the name file6.mp3 I can just look for index 6 since it will be the same as the index for file6.mp3.

In conclusion it all works.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.