mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
BUGIFX: generate avatars when using S3 store
This commit is contained in:
parent
5fd4d88491
commit
76d373161d
1 changed files with 5 additions and 2 deletions
|
@ -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 a new issue