mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 12:09:04 +01:00
parent
a4c500176b
commit
04046a4983
1 changed files with 3 additions and 1 deletions
|
@ -27,9 +27,11 @@ module Remotable
|
||||||
|
|
||||||
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/)
|
matches = response.headers['content-disposition']&.match(/filename="([^"]*)"/)
|
||||||
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1]
|
filename = matches.nil? ? parsed_url.path.split('/').last : matches[1]
|
||||||
|
basename = SecureRandom.hex(8)
|
||||||
|
extname = File.extname(filename)
|
||||||
|
|
||||||
send("#{attachment_name}=", StringIO.new(response.to_s))
|
send("#{attachment_name}=", StringIO.new(response.to_s))
|
||||||
send("#{attachment_name}_file_name=", filename)
|
send("#{attachment_name}_file_name=", basename + extname)
|
||||||
|
|
||||||
self[attribute_name] = url if has_attribute?(attribute_name)
|
self[attribute_name] = url if has_attribute?(attribute_name)
|
||||||
rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
|
rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError, Addressable::URI::InvalidURIError => e
|
||||||
|
|
Loading…
Reference in a new issue