bugfix: fix file uploads not showing original file name

fixes: #1246
This commit is contained in:
Vishal Pandey 2020-09-21 18:42:30 +05:30 committed by GitHub
parent ea6577af6d
commit 313b2da703
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -50,7 +50,7 @@ class Messages::Facebook::MessageBuilder
def attach_file(attachment, file_url)
file_resource = LocalResource.new(file_url)
attachment.file.attach(io: file_resource.file, filename: file_resource.tmp_filename, content_type: file_resource.encoding)
attachment.file.attach(io: file_resource.file, filename: file_resource.filename, content_type: file_resource.encoding)
rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError => e
Rails.logger.info "invalid url #{file_url} : #{e.message}"
end

View file

@ -35,4 +35,8 @@ class LocalResource
def tmp_folder
Rails.root.join('tmp')
end
def filename
File.basename(uri.path)
end
end