carrierwaveuploader / carrierwave-aws

AWS-SDK storage adapter for CarrierWave
MIT License
409 stars 107 forks source link

Allow to use a directory inside the bucket #165

Closed fidalgo closed 4 years ago

fidalgo commented 4 years ago

I would like to have my bucket organised by the two environments:

  1. production
  2. staging

But in the configuration, I can only set the S3 bucket, not a directory. I could change in the uploaders itself but would be nice to have central place where I can configure this.

There's something I've missed from the docs?

sorentwo commented 4 years ago

S3 doesn't have directories, only paths. This is something that's provided by carrierwave itself. You'll need to use a standard prefix for all of your uploaders by changing the "storage directory": https://github.com/carrierwaveuploader/carrierwave#changing-the-storage-directory

fidalgo commented 4 years ago

@sorentwo right, but this way I need to change store_dir and cache_dir for all the uploaders. It would be nice to have a way to specify a common path, that will come before those. Some cases I think this is useful:

sorentwo commented 4 years ago

You can accomplish that with modules/includes within your application, at least that's how I've handled common prefixes in the past. Otherwise I suggest using separate buckets for each environment. It doesn't cost any more to have multiple buckets and you get easy environment based settings.