File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -42,14 +42,16 @@ def handle_html_start_tag(line, &block)
42
42
next unless last_el . type == :html_element && last_el . value == 'img' && last_el . attr [ 'src' ]
43
43
44
44
uri = URI . parse ( ActionController ::Base . helpers . strip_tags ( last_el . attr [ 'src' ] . strip ) )
45
- contents = Net ::HTTP . get ( uri )
45
+ response = Net ::HTTP . get_response ( uri )
46
+ body = response . body
46
47
47
48
bucket_name = s3_secrets [ :uploads_bucket_name ]
48
- key = "#{ secrets . environment_name } /#{ Digest ::SHA2 . new . update ( contents ) . to_s } #{ File . extname ( uri . path ) } "
49
+ key = "#{ secrets . environment_name } /#{ Digest ::SHA2 . new . update ( body ) . to_s } #{ File . extname ( uri . path ) } "
49
50
50
51
s3_client . put_object (
51
- body : StringIO . new ( contents ) ,
52
+ body : StringIO . new ( body ) ,
52
53
bucket : bucket_name ,
54
+ content_type : response [ 'content-type' ] || 'application/octet-stream' ,
53
55
key : key
54
56
)
55
57
You can’t perform that action at this time.
0 commit comments