carrierwaveuploader / carrierwave

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
https://github.com/carrierwaveuploader/carrierwave
8.77k stars 1.66k forks source link

Ability to (partially) set filename for versions #56

Closed seidtgeist closed 14 years ago

seidtgeist commented 14 years ago

I had the following use case:

DocumentUploader

Problem: There's no obvious way to modify the filename ONLY of a specific version. If I set the uploader's filename method all versions (including the original) will be affected.

So I propose: If a version does a format conversion its filename should probably also get the appropriate extension. It sounds like a sensible default. I guess the current behavior can't possibly make any sense.

In order to make it work I monkey-patched the version class like this (bad idea, but works):

version :thumb do
  resize_to_fill 200, 200
  convert :png
  def full_filename(for_file)
    [version_name, for_file].compact.join('_') + '.png'
  end
end
jnicklas commented 14 years ago

The solution here would be to provide some kind of hook to overwrite the extension, kind of like we do with the filename. That way the RMagick module could hook into that and add whatever extension it needs.

This is sort of a nice to have, considering how long this ticket has been open, maybe there's not too much interest?

seidtgeist commented 14 years ago

Not anymore. Given nobody replied to this I think we can forget about it.