How to download files from Amazon S3 buckets?

I’ve found this post with an S3 implementation:

http://web-b1.anscamobile.com/code/amazon-s3-rest-api-implementation-corona

However it’s a few years old, so before I started setting it up I wanted to know if anyone has used it recently, and is the code there still up to date?

There is also a comment towards the bottom of that page that interests me:

For those worried about the AWS secret key:

You should NEVER ship an app with your secret key. I would not even consider leaving this key on a server.
Anyone with access to your secret key can take over your account, and you will pick up the bill.

One solution is to create a bogus account and use that, as suggested. But Amazon actually supports public GET, so you can easily do content downloading without authentication.

Does anyone know how we would set that up? We have some json files that users pull down from our server at the moment. They do not contain any secure info, they just adjust various settings within the app. We also don’t need to be able to upload anything from the app (at the moment).

So public GET would be great, as it means we wouldn’t need to put our access keys anywhere at all.

Does anyone have any experience of working with S3 in Corona?

Thanks

I don’t like to bump, but does anyone have any experience with using S3 and Corona?

If you can set the file PUBLIC in your S3 bucket, then you could simply do a network.download with a GET. This is what we are doing for data files that must be used in our app.

 local function networkListener( event ) if event.isError then -- your error code here elseif event.phase == "progress" then local percentage = math.round( event.bytesTransferred / event.bytesEstimated \* 100 ) -- show the percentage somewhere in the ui... elseif event.phase == "ended" then -- your done, if you need to do something with success, this is the place end end local params = { progress = true } network.download( sourceDate, -- your s3 public URL "GET", networkListener, params, tmpDownloadDataFile, -- the name to use for the downloaded file system.TemporaryDirectory -- where you want to store it )

Nick

Wow, I didn’t realise it was so simple  :o   

I thought that it would need to do some special bucket accessing stuff.

Thanks!

I don’t like to bump, but does anyone have any experience with using S3 and Corona?

If you can set the file PUBLIC in your S3 bucket, then you could simply do a network.download with a GET. This is what we are doing for data files that must be used in our app.

 local function networkListener( event ) if event.isError then -- your error code here elseif event.phase == "progress" then local percentage = math.round( event.bytesTransferred / event.bytesEstimated \* 100 ) -- show the percentage somewhere in the ui... elseif event.phase == "ended" then -- your done, if you need to do something with success, this is the place end end local params = { progress = true } network.download( sourceDate, -- your s3 public URL "GET", networkListener, params, tmpDownloadDataFile, -- the name to use for the downloaded file system.TemporaryDirectory -- where you want to store it )

Nick

Wow, I didn’t realise it was so simple  :o   

I thought that it would need to do some special bucket accessing stuff.

Thanks!