Hi,
I’m not sure if it’s a bug, but after encoding an URL I always get the unsupported URL after I try to download the image:
local function networkListener( event ) if ( event.isError ) then print( "Network error - download failed: ", event.response ) elseif ( event.phase == "began" ) then print( "Progress Phase: began" ) elseif ( event.phase == "ended" ) then print( "Displaying response image file" ) myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 ) myImage.alpha = 0 transition.to( myImage, { alpha=1.0, x = display.contentCenterX, y = display.contentCenterY } ) end end local params = {} params.progress = true local link = "http://docs.coronalabs.com/images/simulator/image-mask-base2.png" string.urlEncode = require('socket.url').escape network.download( string.urlEncode(link), "GET", networkListener, params, "helloCopy.png", system.TemporaryDirectory )
Same thing happens when I try with this function:
function string.urlEncode( str ) if ( str ) then str = string.gsub( str, "\n", "\r\n" ) str = string.gsub( str, "([^%w])", function (c) return string.format( "%%%02X", string.byte(c) ) end ) str = string.gsub( str, " ", "+" ) end return str end