{"action":"created","issue":{"url":"https://api.github.com/repos/markevans/dragonfly/issues/386","repository_url":"https://api.github.com/repos/markevans/dragonfly","labels_url":"https://api.github.com/repos/markevans/dragonfly/issues/386/labels{/name}","comments_url":"https://api.github.com/repos/markevans/dragonfly/issues/386/comments","events_url":"https://api.github.com/repos/markevans/dragonfly/issues/386/events","html_url":"https://github.com/markevans/dragonfly/issues/386","id":56982041,"number":386,"title":"Incorrect Mime type for remote url without file extension","user":{"login":"speedmax","id":3823,"avatar_url":"https://avatars.githubusercontent.com/u/3823?v=3","gravatar_id":"","url":"https://api.github.com/users/speedmax","html_url":"https://github.com/speedmax","followers_url":"https://api.github.com/users/speedmax/followers","following_url":"https://api.github.com/users/speedmax/following{/other_user}","gists_url":"https://api.github.com/users/speedmax/gists{/gist_id}","starred_url":"https://api.github.com/users/speedmax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speedmax/subscriptions","organizations_url":"https://api.github.com/users/speedmax/orgs","repos_url":"https://api.github.com/users/speedmax/repos","events_url":"https://api.github.com/users/speedmax/events{/privacy}","received_events_url":"https://api.github.com/users/speedmax/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-09T02:36:04Z","updated_at":"2016-03-19T09:29:41Z","closed_at":null,"body":"file = Dragonfly.app.fetch_url(\"https://ununsplash.imgix.net/photo-1415302199888-384f752645d0?dpr=0.25&fit=crop&fm=jpg&h=700&q=75&w=1050\")\r\n\r\nFile mime type returns octet stream instead of images/jpeg.\r\n\r\n    > file.mime_type\r\n     => \"application/octet-stream\"\r\n\r\nWhile there is correct content type set in HTTP response header\r\n\r\ncurl -i -XHEAD \"https://unsplash.imgix.net/photo-1414005987108-a6d06de8769f?dpr=0.25&fit=crop&fm=jpg&q=75&w=1050\"\r\n\r\n    HTTP/1.1 200 OK\r\n    Date: Mon, 09 Feb 2015 02:35:19 GMT\r\n    Server: imgix-fe\r\n    Last-Modified: Wed, 22 Oct 2014 19:26:28 GMT\r\n    X-Imgix-FramesIn: 1\r\n    Cache-Control: max-age=315360000\r\n    Content-Length: 18147\r\n    Accept-Ranges: bytes\r\n    Age: 1214\r\n    Content-Type: image/jpeg\r\n    X-Imgix-Request-ID: 1d6d4a7338bd34a04fa87167a3be751f98a421ca"},"comment":{"url":"https://api.github.com/repos/markevans/dragonfly/issues/comments/198673890","html_url":"https://github.com/markevans/dragonfly/issues/386#issuecomment-198673890","issue_url":"https://api.github.com/repos/markevans/dragonfly/issues/386","id":198673890,"user":{"login":"ShogunPanda","id":201101,"avatar_url":"https://avatars.githubusercontent.com/u/201101?v=3","gravatar_id":"","url":"https://api.github.com/users/ShogunPanda","html_url":"https://github.com/ShogunPanda","followers_url":"https://api.github.com/users/ShogunPanda/followers","following_url":"https://api.github.com/users/ShogunPanda/following{/other_user}","gists_url":"https://api.github.com/users/ShogunPanda/gists{/gist_id}","starred_url":"https://api.github.com/users/ShogunPanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ShogunPanda/subscriptions","organizations_url":"https://api.github.com/users/ShogunPanda/orgs","repos_url":"https://api.github.com/users/ShogunPanda/repos","events_url":"https://api.github.com/users/ShogunPanda/events{/privacy}","received_events_url":"https://api.github.com/users/ShogunPanda/received_events","type":"User","site_admin":false},"created_at":"2016-03-19T09:29:40Z","updated_at":"2016-03-19T09:29:40Z","body":"There is also a third way, which worked for me using small monkey patching.\r\nBasically when the extension is `nil`, I re-run the Analyzer and return the format as the file extension.\r\n\r\nHere's the patch. @markevans Do you think you can add it to the real code?\r\n\r\n```ruby\r\nmodule Dragonfly\r\n  module HasFilename\r\n    def ext\r\n      if name\r\n        File.extname(name)[/\\.(.*)/, 1] if name\r\n      else\r\n        ImageMagick::Analysers::ImageProperties.new.call(self)[\"format\"].gsub(\"jpeg\", \"jpg\")\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nHope this helps!\r\n  Paolo\r\n"}}