I am trying to understand exactly how to setup a bucket that is generally private but allows anonymous uploads with restrictions. The specific criteria are:
- The bucket is mostly private and requires my key/secret to add/remove/update/list files.
- There is a "directory" (i.e. key prefix) called "incoming" that will allow anonymous users to upload content to but not list.
- The bucket has a one day expiration on all content. As a bonus I would like the "incoming" directory to have a 30 minute expiration although if that is not possible a one day expiration for the whole bucket will do.
- Files with the "incoming" prefix would be limited in size per object.
- I might want to also limit objects with the "incoming" prefix to only certain content types.
Questions I have are:
- Would it be better to simply create two buckets. One for my incoming files and one for my own personal processing and storage?
- What would the code look like that for a file to be uploaded into the incoming directory. Ideally I would like to avoid a dependency on a S3 library and just use HTTP calls. Bonus points if you can show me the right direction on this in Ruby. :)
The expiration seems settable via the S3 Management Console but is only limited to 1 day as the smallest expiration. Can I put a decimal in that field? Permissions seem to apply to an entire bucket instead of just a prefix. This is making me think I just need two buckets. If I keep with one bucket I think I need to create an IAM policy and apply that to the bucket but it is beyond my limited knowledge of S3 and I want to ensure I don't leave a hole in the permissions that allow people to do more than I want them to.
I have found lots of documentation on doing anonymous uploads to S3 via a HTTP form post. I could adapt that into code but I am wondering since I am in application code (and not a HTTP form post) is there an easier way?