{"action":"created","issue":{"url":"https://api.github.com/repos/balvig/spyke/issues/57","labels_url":"https://api.github.com/repos/balvig/spyke/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/balvig/spyke/issues/57/comments","events_url":"https://api.github.com/repos/balvig/spyke/issues/57/events","html_url":"https://github.com/balvig/spyke/issues/57","id":102622579,"number":57,"title":"Handle binary responses from APIs","user":{"login":"risinglf","id":875223,"avatar_url":"https://avatars.githubusercontent.com/u/875223?v=3","gravatar_id":"","url":"https://api.github.com/users/risinglf","html_url":"https://github.com/risinglf","followers_url":"https://api.github.com/users/risinglf/followers","following_url":"https://api.github.com/users/risinglf/following{/other_user}","gists_url":"https://api.github.com/users/risinglf/gists{/gist_id}","starred_url":"https://api.github.com/users/risinglf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/risinglf/subscriptions","organizations_url":"https://api.github.com/users/risinglf/orgs","repos_url":"https://api.github.com/users/risinglf/repos","events_url":"https://api.github.com/users/risinglf/events{/privacy}","received_events_url":"https://api.github.com/users/risinglf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-23T13:59:06Z","updated_at":"2015-09-03T08:57:42Z","closed_at":"2015-09-03T08:57:42Z","body":"Hi there,\r\n\r\nHow can I properly handle with API enpoints that responds a raw file (such as a PDF)?\r\n\r\nEg:\r\n\r\nmy API has an endpoint called GET /support_files/:id/download\r\n\r\nhow can I handle with Spyke the request\r\n\r\n```\r\nSupportFile.find(id).get(:download)\r\n```\r\n\r\nI use this JSONParser as middleware:\r\n```\r\nclass JSONParser < Faraday::Response::Middleware\r\n  def parse(body)\r\n    json = MultiJson.load(body, symbolize_keys: true)\r\n    {\r\n        data: json[:data],\r\n        metadata: json[:meta],\r\n        errors: json[:errors]\r\n    }\r\n  rescue MultiJson::ParseError, TypeError => e\r\n    {errors: {base: [error: e.message]}}\r\n  end\r\nend\r\n```\r\n\r\nYou guys suggest to create another middleware to handle raw data responses? It would be great an example to do that in the wiki ;)\r\n\r\nThank you so much.\r\n"},"comment":{"url":"https://api.github.com/repos/balvig/spyke/issues/comments/137383485","html_url":"https://github.com/balvig/spyke/issues/57#issuecomment-137383485","issue_url":"https://api.github.com/repos/balvig/spyke/issues/57","id":137383485,"user":{"login":"balvig","id":104138,"avatar_url":"https://avatars.githubusercontent.com/u/104138?v=3","gravatar_id":"","url":"https://api.github.com/users/balvig","html_url":"https://github.com/balvig","followers_url":"https://api.github.com/users/balvig/followers","following_url":"https://api.github.com/users/balvig/following{/other_user}","gists_url":"https://api.github.com/users/balvig/gists{/gist_id}","starred_url":"https://api.github.com/users/balvig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balvig/subscriptions","organizations_url":"https://api.github.com/users/balvig/orgs","repos_url":"https://api.github.com/users/balvig/repos","events_url":"https://api.github.com/users/balvig/events{/privacy}","received_events_url":"https://api.github.com/users/balvig/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T08:57:42Z","updated_at":"2015-09-03T08:57:42Z","body":"@risinglf hey there! I guess it depends completely on what you want to do! Spyke is meant to build objects from json/xml/etc responses so giving it a binary file probably won't end well :wink: \r\nI would probably consider not using Spyke and handling it with a separate class, so it's probably a bit out of scope for this project! :bow: "}}