Amazon S3 Lite Plugin

Hi, this plugin is great thanks. For s3:listObjects, I see in the plugin documentation there are startAfter and paging parameters. In what sort order are the objects returned with listObjects?  More importantly, is there any way to have the objects retrieved in date order so that it retrieves the most recent objects first?  This way we can use maxKeys=10 and show the most recent 10 objects (last in first out), then use nextToken to get objects 11-20 etc.  So the first object returned would be the one most recently added to the bucket, etc…

Btw, this plugin has worked out great for image uploads. Thanks for the great solution!

Hi,

The listing of objects is using the Amazon S3 API as outlined here https://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html

When building the plugin, I didn’t see anything in relation to sorting by date, so I think you would need to use a naming/keyspace scheme that will sort lexicographically for your needs, as that seems to be the only way the sorting is handled on the S3 side.

Amazon S3 lists objects in UTF-8 character encoding in lexicographical order.

Another option would be to being back all the images and sort them using Lua against the timestamp returned. But again, depending on how many images you would end up returning, you would still probably need to come up with a naming/keyspace scheme so you don’t bring back all images, which could produce a heavy network load depending on the amount of images.

You could store the image paths in a database, which would then make it trivial to get the sorting you want, but of course that adds an extra layer of complexity. Coronium Core is a fairly simple solution for database needs if you want to go that route. Or you can roll your own as Core might be more than you need.

It’s certainly disappointing from the S3 side that there are not better sorting options.

Thanks for using the plugin!

-dev

Ok sounds good. Thanks for the detailed info!  I had thought of storing the keys in a database but I was hoping not to since my hosting service isn’t too reliable as far as availability. AWS S3 seems so much more reliable. I’ll check out Coronium or figure out a naming scheme… I guess I can put some kind of timestamp as a prefix like a20180312_124222 for date and time. I assume I’d need to use a database anyway for other kinds of filtering down the road so maybe I should just put the effort in now :slight_smile:

Thanks again!

Hi,

I’m a big fan of DigitalOcean. They have a $5 one-click MySQL box.

-dev

Great to know I’ll have to check them out. You’ve found it to be fast and rarely goes down?  I’ve been doing SQL for 20 years… but have never done sql in the cloud :)   How do you submit a query to the database?  Is there a webservice for that or would we use network.request to do a GET or POST?  Or would I have to write php code on the server?

Hi,

Well there are various ways to handle it, so yes to most all you mentioned. The DO box has an administration tool installed called 

phpMyAdmin pre-installed which is probably the most popular cloud based tool.

But, that is what Coronium Core does for you, it is written specifically to work nicely with Corona. You can easily wrangle SQL on the client-side or server-side using Lua.

Hope that helps.

-dev

Thanks so much for the great tips, I’m going to check those out

Hi,

I am using the Amazon S3 Lite Plugin and it is great, but I need to get the URL (Link) back of the uploaded file. 

How can I do that?

I can see that there is a possibility of getting the size of the file: objects.size - but how to get other metadata back from the uploaded file - I need the Link information :slight_smile:

I have tried with objects[i].link and objects[i].url - but it is returning nil.

Thanks.

Hi,

I am facing an issue with Amazon S3 Lite Plugin.
While trying to download the file from s3 using s3:getObject(), Its crashing after the file download is completed with the following error.

bad argument #1 to ‘find’ (string expected, got table)

12:59:05.093  stack traceback:

12:59:05.093  [C]: in function ‘find’

12:59:05.093  ?: in function ‘ParseXmlText’

12:59:05.093  ?: in function ‘get_error_msg’

12:59:05.093  ?: in function <?:384>

Let me the know how to resolve this.

Thanks.

Got same error - for ParseXmlText
But plugin does works fine in a demo project.
same error in the demo project.