Export Files From A Corona App To A Server?

Hi,

I wonder if anyone knows whether Corona has a feature to allow files created by my app to be uploaded to a server?

My app allows the user to record audio files themselves which are stored on the device. I would like users to be able to share these files with other devices so was hoping there would be a way to allow users to tap an “upload” button and a file would be saved to a server.

I can handle the server side stuff using ASP.Net but it’s just the export / sending of audio to the server from Corona I’m stuck with.

Thanks in advance,

Ian

Hi there,

Have you tried using the network.upload() API (http://docs.coronalabs.com/daily/api/library/network/upload.html)?  Sounds like it’s exactly what you’re looking for.

  • Andrew

Thanks Andrew - yes that looks perfect. Much appreciated.

Do you have any idea how I would pass an ID through with the file to save to a database at the same time so it could be referenced later? Could this be sent through in the params.headers?

Or, thinking about it, presumably I could pass an ID through in the querystring of the URL - i.e.: set the url to something like http://mywebsite.com/fileupload.aspx?id=1234 - as long as characters like ? are allowed in the url parameter which I imagine they are.

Thanks,

Ian

Hi there, Either method should work. If you include it as a parameter in the HTTP request, you’ll just want to make sure you URL encode it. (You’ll find a few Lua implementations of URL encoding functions if you google it). - Andrew

Thanks Andrew - really appreciate you taking the time to reply.

Ok - all makes sense and looks to be exactly what I was looking for. Will look into the URL encoding.

All the best,

Ian

Hi there,

Have you tried using the network.upload() API (http://docs.coronalabs.com/daily/api/library/network/upload.html)?  Sounds like it’s exactly what you’re looking for.

  • Andrew

Thanks Andrew - yes that looks perfect. Much appreciated.

Do you have any idea how I would pass an ID through with the file to save to a database at the same time so it could be referenced later? Could this be sent through in the params.headers?

Or, thinking about it, presumably I could pass an ID through in the querystring of the URL - i.e.: set the url to something like http://mywebsite.com/fileupload.aspx?id=1234 - as long as characters like ? are allowed in the url parameter which I imagine they are.

Thanks,

Ian

Hi there, Either method should work. If you include it as a parameter in the HTTP request, you’ll just want to make sure you URL encode it. (You’ll find a few Lua implementations of URL encoding functions if you google it). - Andrew

Thanks Andrew - really appreciate you taking the time to reply.

Ok - all makes sense and looks to be exactly what I was looking for. Will look into the URL encoding.

All the best,

Ian