diff --git a/lib/dragonfly/job/fetch_url.rb b/lib/dragonfly/job/fetch_url.rb index 8334e1536..287627e00 100644 --- a/lib/dragonfly/job/fetch_url.rb +++ b/lib/dragonfly/job/fetch_url.rb @@ -44,6 +44,11 @@ def apply update_from_data_uri else response = get_following_redirects(url) + if content_disposition = response.header["content-disposition"].presence + if content_disposition_match = content_disposition.match(/filename="(.+)"/) + @filename = content_disposition_match[1] + end + end job.content.update(response.body || "", 'name' => filename, 'mime_type' => response.content_type) end end