mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
BUGIFX: generate avatars when using S3 store
This commit is contained in:
parent
5fd4d88491
commit
76d373161d
|
@ -1,3 +1,5 @@
|
|||
require "open-uri"
|
||||
|
||||
class FileHelper
|
||||
|
||||
def self.is_image?(filename)
|
||||
|
@ -7,11 +9,12 @@ class FileHelper
|
|||
def self.download(url, max_file_size, tmp_file_name)
|
||||
raise Discourse::InvalidParameters unless url =~ /^https?:\/\//
|
||||
|
||||
extension = File.extname(URI.parse(url).path)
|
||||
uri = URI.parse(url)
|
||||
extension = File.extname(uri.path)
|
||||
tmp = Tempfile.new([tmp_file_name, extension])
|
||||
|
||||
File.open(tmp.path, "wb") do |f|
|
||||
downloaded = open(url, "rb", read_timeout: 5)
|
||||
downloaded = uri.open("rb", read_timeout: 5)
|
||||
while f.size <= max_file_size && data = downloaded.read(max_file_size)
|
||||
f.write(data)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user