Dynamically Defined URLs on S3

I realize that S3 buckets do not contain folders, but that they do
permit the use of filenames which contain the “/” character, thereby
giving the appearance of folders (“pseudofolders”). I want to be able
to save files in an S3 bucket, with pseudofolders where the
pseudofolders are dynamically assigned based on the category of the
file and the type of file.

For example, if I was saving John’s vacation photos, I would want them
to appear in my bucket (“mybucket”) with the owner_name of ‘john’ and
category ‘vacation’, so that a photo having a filename ‘photo.jpg’
would appear in S3 as
http://mybucket.s3.amazonaws.com/john/vacation/photo.jpg.
How do I accomplish this using paperclip?

I do not understand what I have to do to modify the
default :url / :path so that I can create the desired result. In
general, I would like to be able to control the full “path” between
“mybucket” (the S3 bucket) and “filename”, so that I can access the
file at
http://mybucket.s3.amazonaws.com//{whatever_i_dynamically_create}/filename.

Sorry, I should have mentioned that I’m using Paperclip.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs