Created
March 13, 2011 03:49
-
-
Save phlipper/867845 to your computer and use it in GitHub Desktop.
normalize filenames for use with s3 authenticated urls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Paperclip.interpolates :normalized_basename do |attachment, style| | |
filename = attachment.instance.data_file_name | |
basename = File.basename(filename, File.extname(filename)) | |
basename.gsub(/[^\w\d_-]/i, " ").gsub(/\s+/, "-") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment