Permalink
Browse files

fix 上传的文件没有扩展名时 存储的文件名后缀会是 ..

  • Loading branch information...
1 parent 26dd853 commit d0a8af80a6bbde5a42969ecc85fd278178b67cfd @fushang318 fushang318 committed Jun 8, 2012
Showing with 4 additions and 4 deletions.
  1. +2 −2 app/models/note.rb
  2. +2 −2 config/initializers/peperclip_random_uuid_filename.rb
View
@@ -7,8 +7,8 @@ class Kind
belongs_to :creator, :class_name=>"User"
has_attached_file :attachment,
- :path => '/:class/:attachment/:id/:style/:basename.:extension',
- :url => "http://storage.aliyun.com/#{OssManager::CONFIG["bucket"]}/:class/:attachment/:id/:style/:basename.:extension",
+ :path => '/:class/:attachment/:id/:style/:filename',
+ :url => "http://storage.aliyun.com/#{OssManager::CONFIG["bucket"]}/:class/:attachment/:id/:style/:filename",
:storage => :oss
def self.compare(syn_task_uuid,note_uuid,client_note_updated_at)
@@ -48,9 +48,9 @@ def assign uploaded_file
# 获取一个随机的文件名
def get_randstr_filename(uploaded_filename)
arr = uploaded_filename.split(".")
- ext_name = arr.length > 1 ? arr.last.downcase : ''
+ ext_name = arr.length > 1 ? ".#{arr.last.downcase}" : ''
- return "#{randstr}.#{ext_name}".strip
+ return "#{randstr}#{ext_name}".strip
end
end
end

0 comments on commit d0a8af8

Please sign in to comment.