Hi everyone,
I’m at my wits end here with this one. I’m trying to download an image file from an online folder and one of three things happen.
-
The event listener that is being called during the “progress” period does not call and the file is never downloaded.
-
The event listener is called but the event.isError is called 3 times and I also get this message
Error: unable to get the receiver data from the DB!
- The Error: unable to get the receiver data form the DB! is printed to the console and the event listener is not called. I have absolutely no idea what this means as I’m just learning the networking functionality of Corona. I do know that it only occurs when I have already attempted to download the file previously and if the file is actually in the online folder.
The Error does not occur if the file is not in the online folder but the event listener’s event.isError is still called 3 times.
Also, I am trying to download this after I have successfully downloaded a .json file and saved it to the system.DocumentsDirectory (code omitted). I’m not sure if making a network request previously affects this at all but I thought I’d mention it just in case.
Please help.
Here is the code.
[lua]local eventDownloadListener
local downloadParams = {progress = true, timeout = 10}
local nameOfFile = “events/eventName.png”
local URLPath = “http://myURLpath/eventPictures/eventName.png”
local directory = system.DocumentsDirectory
network.download(URLPath, “GET”, eventDownloadListener, downloadParams, nameOfFile, directory)
function eventDownloadListener(event)
if (event.isError or event.status == 404) then – If there is any kind of error in the download process
print(“There has been an error downloading the file”)
elseif phase == “began” then
print(“Starting to download file”)
elseif phase == “ended” then – When the download has occured successfully
print(“File has downloaded”)
end
end[/lua]