Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter & FireBase : url with special character

I have just find out that my application is having a QA problem.
The user can import pdf or jpeg file using file picker.
During this operation, I am collecting the filename so it can be displayed in a Text widget on a card.
Then, the user is saving his modifications.
The file is then uploaded to Storage. This works fine, and the name for example "user guide.pdf" is recorded properly in Storage.
When the upload if finished, I am collecting the url to I can store it into an array in FireBase.
This is where I am having an issue. The url when it is recorded in FireBase, does not match the original name.
it is now "user%20guide.pdf".
This is causing a problem to my application. I have done some research, but I do not find how to stop this behaving. Please, can you point me to the right direction?
Many thanks

 for (int g = 0; g <  List_Adding_New_Attachements.length; g++) {
        final fileName = List_Adding_New_Attachements[g]
            .split('/')
            .last;
        final destination = fileName;

        attachment_Files = FirebaseApi_Upload_Files_To_Storage.uploadFile(
            destination, List_Adding_New_Attachements[g]);
        setState(() {});

        if (attachment_Files == null) return;


>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I also had the same issue and I was able to make it work by using decodeComponent() method from URI.

So what you could do is wherever you check for your file name, add this to your code:

Uri.decodeComponent("user%20guide.pdf") // user guide.pdf

More information related to Uri.decodeComponent can be found here!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading