local function networkListener( event ) if event.isError then -- change status back to 'nosend' else if event.phase == "ended" then if event.status == 200 then -- change status to 'send' end end end return true end
in case app suspend and then back to screen - all ok, status change to ‘send’ or ‘nosend’ depending on the event
in case app suspend and then exit - status dont change, but photo may be delivered to server
My question: whether I can to check delivery for a server ?
Have a Corona team a instructions or a examples: network.requests with different app status (applicationSuspend/applicationExit)?
Uploading files is not easy. There are dozens of ways to upload files and they are all 100% dependent on the server’s expectations. Unless you know what the server’s expectations are, you can’t successfully upload files. The network.upload() is a helper function around network.request(), but it’s designed for a super-simple case of where the server is getting a stream of data and saving it. Many servers expect Multi-part MIME encoding. Others may want different HTTP headers included that say what the file type is. network.upload() is not a magical API.
As far as suspending/exiting goes, you only have a brief few cycles to do anything before the OS stops the app. The network.request API supports progress checks, but I’m not sure if it’s accurate enough to allow you to resume the file. The best you could do is cancel the download, assume it’s not there and try the upload when the app comes back.
Uploading files is not easy. There are dozens of ways to upload files and they are all 100% dependent on the server’s expectations. Unless you know what the server’s expectations are, you can’t successfully upload files. The network.upload() is a helper function around network.request(), but it’s designed for a super-simple case of where the server is getting a stream of data and saving it. Many servers expect Multi-part MIME encoding. Others may want different HTTP headers included that say what the file type is. network.upload() is not a magical API.
As far as suspending/exiting goes, you only have a brief few cycles to do anything before the OS stops the app. The network.request API supports progress checks, but I’m not sure if it’s accurate enough to allow you to resume the file. The best you could do is cancel the download, assume it’s not there and try the upload when the app comes back.