{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/815","labels_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/815/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/815/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/815/events","html_url":"https://github.com/aws/aws-sdk-js/issues/815","id":118790645,"number":815,"title":"APIGateway getSdk data.body is not a buffer","user":{"login":"SamVerschueren","id":1913805,"avatar_url":"https://avatars.githubusercontent.com/u/1913805?v=3","gravatar_id":"","url":"https://api.github.com/users/SamVerschueren","html_url":"https://github.com/SamVerschueren","followers_url":"https://api.github.com/users/SamVerschueren/followers","following_url":"https://api.github.com/users/SamVerschueren/following{/other_user}","gists_url":"https://api.github.com/users/SamVerschueren/gists{/gist_id}","starred_url":"https://api.github.com/users/SamVerschueren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamVerschueren/subscriptions","organizations_url":"https://api.github.com/users/SamVerschueren/orgs","repos_url":"https://api.github.com/users/SamVerschueren/repos","events_url":"https://api.github.com/users/SamVerschueren/events{/privacy}","received_events_url":"https://api.github.com/users/SamVerschueren/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aws/aws-sdk-js/labels/Feedback%20Requested","name":"Feedback Requested","color":"e102d8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-25T09:06:56Z","updated_at":"2015-11-26T07:04:30Z","closed_at":null,"body":"Hi\r\n\r\nI am using the `apigateway.getSdk` method to download the zip file of my SDK. This way I can integrate that with my gulpfile to make sure I always have the latest version.\r\n\r\nThe documentation can be found [here](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#getSdk-property).\r\n\r\nIt states that the callback returns a `data` object with the property `body`, which is a `String`, `Buffer`, etc. So I tried that call and write the `data.body` directly as zip file to my filesystem.\r\n\r\n```js\r\napigateway.getSdk(params, function (err, data) {\r\n    if(err) {\r\n        // handle error\r\n        return;\r\n    }\r\n\r\n    fs.writeFileSync('apigateway.zip', data.body);\r\n});\r\n```\r\n\r\nIt didn't work as turned out, `data.body` is not a `Buffer`, but a `string`. So I tried to convert it into a buffer with `new Buffer(data.body)` and tried every possible encoding argument there is. Nothing worked for me.\r\n\r\nBut, what did work was the following.\r\n\r\n```js\r\nvar request = apigateway.getSdk(params, function (err, data) {\r\n    if(err) {\r\n        // handle error\r\n        return;\r\n    }\r\n\r\n    fs.writeFileSync('apigateway.zip', request.response.httpResponse.body);\r\n});\r\n```\r\n\r\nSo it turns out, the property in the `httpResponse` is a `Buffer` which can be written directly as zip file.\r\n\r\nIs this an issue in the library or should I convert the `data.body` property body with a different function?\r\n\r\nKind regards,\r\nSam"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/comments/159827509","html_url":"https://github.com/aws/aws-sdk-js/issues/815#issuecomment-159827509","issue_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/815","id":159827509,"user":{"login":"SamVerschueren","id":1913805,"avatar_url":"https://avatars.githubusercontent.com/u/1913805?v=3","gravatar_id":"","url":"https://api.github.com/users/SamVerschueren","html_url":"https://github.com/SamVerschueren","followers_url":"https://api.github.com/users/SamVerschueren/followers","following_url":"https://api.github.com/users/SamVerschueren/following{/other_user}","gists_url":"https://api.github.com/users/SamVerschueren/gists{/gist_id}","starred_url":"https://api.github.com/users/SamVerschueren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamVerschueren/subscriptions","organizations_url":"https://api.github.com/users/SamVerschueren/orgs","repos_url":"https://api.github.com/users/SamVerschueren/repos","events_url":"https://api.github.com/users/SamVerschueren/events{/privacy}","received_events_url":"https://api.github.com/users/SamVerschueren/received_events","type":"User","site_admin":false},"created_at":"2015-11-26T07:04:29Z","updated_at":"2015-11-26T07:04:29Z","body":"@chrisradek Alright, thanks for the information. So at the moment, `result.body` is not very useful? \r\n\r\nThanks for the example with streams, might come in handy :)."}}