Paperclip 会自动清理文件名吗? [英] Does Paperclip automatically clean up filenames?
问题描述
我使用 Thoughtbot 的 Paperclip gem 来处理文件上传.
I'm using Thoughtbot's Paperclip gem to handle file uploads.
我发现当我上传文件名中带有空格的文件时,它会被存储,其中空格替换为下划线.
I'm finding that when I upload a file with spaces in the filename, it gets stored with the spaces replaced with underscores.
那很好.
我也尝试上传一个带有特殊字符的文件,比如 ~
等等,它们都被下划线替换了.
I also tried uploading a file with special characters like ~
and so on and they all got replaced with underscores.
太好了.正是我想要的.
Great. Exactly what I want.
但是为什么会这样呢?
我在模型中所做的只是......
All I'm doing in my model is...
has_attached_file(
file_somefile,
:path => ":rails_root/public/system/other/path/elements/:basename.:extension"
)
这是回形针的默认行为吗?
Is this Paperclip's default behavior?
推荐答案
好的,经过一番搜索,我找到了 这篇博文 在底部说,Paperclip 实际上对文件名做了一些最小的处理.
OK, after a little more searching, I found this blog post that says, down at the bottom, that Paperclip actually does some minimal processing of filenames.
这篇关于Paperclip 会自动清理文件名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!