Amazon S3 only accepting files with no spaces, no numbers in the title?

妖精的绣舞 提交于 2019-12-06 03:19:29

For part two this should do it:

@s = "Really Important!*() Document version#123123.newest.pdf"
@s.gsub!(' ','_').downcase! #this will make everything lowercase and replace all spaces with underscores
@s.gsub!(/[^a-zA-Z._]+/,'') #this will remove all numbers and special characters except . and _
puts @s #prints "really_important_document_version.newest.pdf"

Edit: After some more research into paperclip I found the following: http://blog.wyeworks.com/2009/7/13/paperclip-file-rename

Check that link out, I believe it is what you are looking for.

Edit 2: In my initial read of your post I missed the part about pulling out numbers as well, I have modified the regulat expression code to account for that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!