local function downloadListener( 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" ) print("File name: /"..event.response.filename) cameraImage = display.newImage( event.response.filename, event.response.baseDirectory, 64, 36 ) cameraImage.x = display.contentCenterX -- The code crashes here as the image is nil cameraImage.y = display.contentCenterY-100 cameraImage.alpha = 0 transition.to( cameraImage, { alpha=1.0 } ) end end local function changeCamera() local params = {} params.progress = "download" params.response = { filename = "corona.jpg", baseDirectory = system.DocumentsDirectory } print(system.DocumentsDirectory) network.request( "\<URL\>", -- Can't include the actual URL for security purposes "GET", downloadListener, params ) end
I’m having a problem with network.request(), in that it’s silently failing to download a file.
A test url provided works just fine; http://docs.coronalabs.com/images/simulator/image-mask-base2.png
The main differences are that the url is using basic authentication (which according to this tutorial, corona is capable of: https://docs.coronalabs.com/tutorial/social/connectREST/index.html) notably with an empty password, and that instead of accessing the file directly, the url links to a .cgi script that gives the file.
The URL (example): http://<username>:@<server>:<port>/image/jpeg.cgi
Tested in any web browser, this url displays the image. However, when I try to use network.request() to GET the image, it throws no errors but also grabs nothing, that is until it tries to use the non-existent image. It also doesn’t write to any file. The code in question is provided.
My real question is, what might be happening, and what can i do to get more verbose info about what’s going on behind the scenes?