'Why is # not escaped?

Feeling a little dumb here. I have this string

http://www.example.com/foo/bar#4.png?token=1441307151_4492f25946a2e8e1414a8bb53dab8a6ba1cf4615

Because the file name is bar#4.png I can't seem to download it on android or ios. But it works if the file name is [email protected]. Is there anything I could do to fix this in one go?

Or do I have to remove the token, get the file name and manually encode it and attach it back to the string?

I'm currently trying to fix this in android.

Additional note : When I try to get the file name, I get it as #4.png for some reason as well.

Would be great if someone could help around!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source