iOS Question Unsupported URL with ImageDownloader

Marco Iannaccone

Member
Licensed User
Longtime User
I found some problems with some image URLs (they are post preview images for WordPress posts, returned by a REST plugin as UTF-8 strings), using ImageDownloader (but I can imagine the problem is related not only to the ImageDownloader class).
When the image URL contains "special characters" (Unicode characters, It seems) like "à" or "°" the downloader can't download the image, logging the problem as "unsupported URL".

Some url examples that dotn't work are (they correctly work when loading them directly in a web browser):
https://www.sdl.tv/wp-content/uploads/2016/08/Spoiler-2°-puntata-balletto.jpg
https://www.sdl.tv/wp-content/uploads/2016/08/Chi-sarà-Padre-Natura.jpg

Can I, somehow, make these URLs work (or pass them differently from the plug-in...)?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You will need to url encode the file names:
B4X:
Dim su As StringUtils
job.Download("https://www.sdl.tv/wp-content/uploads/2016/08/" & su.EncodeUrl("Spoiler-2°-puntata-balletto.jpg", "utf8"))

Note that in most cases this is only required for the query parameters. In that cases you can use Job.Download2.
 
Upvote 0
Top