{"action":"created","issue":{"url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/72","labels_url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/72/comments","events_url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/72/events","html_url":"https://github.com/cloudant/nodejs-cloudant/issues/72","id":91143630,"number":72,"title":"GZip attachments","user":{"login":"random6886","id":11774102,"avatar_url":"https://avatars.githubusercontent.com/u/11774102?v=3","gravatar_id":"","url":"https://api.github.com/users/random6886","html_url":"https://github.com/random6886","followers_url":"https://api.github.com/users/random6886/followers","following_url":"https://api.github.com/users/random6886/following{/other_user}","gists_url":"https://api.github.com/users/random6886/gists{/gist_id}","starred_url":"https://api.github.com/users/random6886/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/random6886/subscriptions","organizations_url":"https://api.github.com/users/random6886/orgs","repos_url":"https://api.github.com/users/random6886/repos","events_url":"https://api.github.com/users/random6886/events{/privacy}","received_events_url":"https://api.github.com/users/random6886/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-26T03:41:00Z","updated_at":"2015-06-26T15:33:09Z","closed_at":null,"body":"This might be already implemented, but I wasn't having any luck looking through here or nano. \r\n\r\n```\r\nvar fs = require('fs');\r\n\r\nalice.attachment.get('rabbit', 'rabbit.png').pipe(fs.createWriteStream('rabbit.png'));\r\n```\r\n\r\nThe above is an example for producing a stream, which I've been able to do successfully. Is there a way to have the stream comeback gzipped though? For example, if I do a:\r\n\r\n```\r\ncurl https://(my_account).cloudant.com/db/doc/attachment --silent --write-out \"%{size_download} - Took: %{time_total}s\\n\" --output /dev/null -u (my_account)\r\n```\r\n\r\nIt produces: `2047050 - Took: 0.993s`\r\n\r\nNow if I include the gzip/deflate header:\r\n\r\n```\r\ncurl https://(my_account).cloudant.com/db/doc/attachment --silent --write-out \"%{size_download} - Took: %{time_total}s\\n\" --output /dev/null -u (my_account) -H \"Accept-encoding: gzip,deflate\"\r\n```\r\n\r\nIt produces: `134440 - Took: 0.383s`\r\n\r\nThanks!\r\n"},"comment":{"url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/comments/115733092","html_url":"https://github.com/cloudant/nodejs-cloudant/issues/72#issuecomment-115733092","issue_url":"https://api.github.com/repos/cloudant/nodejs-cloudant/issues/72","id":115733092,"user":{"login":"glynnbird","id":697925,"avatar_url":"https://avatars.githubusercontent.com/u/697925?v=3","gravatar_id":"","url":"https://api.github.com/users/glynnbird","html_url":"https://github.com/glynnbird","followers_url":"https://api.github.com/users/glynnbird/followers","following_url":"https://api.github.com/users/glynnbird/following{/other_user}","gists_url":"https://api.github.com/users/glynnbird/gists{/gist_id}","starred_url":"https://api.github.com/users/glynnbird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glynnbird/subscriptions","organizations_url":"https://api.github.com/users/glynnbird/orgs","repos_url":"https://api.github.com/users/glynnbird/repos","events_url":"https://api.github.com/users/glynnbird/events{/privacy}","received_events_url":"https://api.github.com/users/glynnbird/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T15:33:08Z","updated_at":"2015-06-26T15:33:08Z","body":"I don't know everything about your application, but I would say \r\n\r\n1. gzipping the output of your content (on its way to the browser) is computationally cheap and saves a ton of bandwidth. If you're using Express, then something like https://github.com/expressjs/compression makes it easy. It's a *little* inefficient to decompress & compress it again, but the advantages for the client are big.\r\n\r\n2. If your Node.js Server is just proxying data between the browser and client, then you could consider just getting the client to communicate with Cloudant directly. With CORS enabled, your web app can make XHR requests to Cloudant without going through your Node.js servers at all. \r\n\r\n3. Doing some sanity checking, it seems to me that adding \"Accept-encoding: gzip,deflate\" only compresses attachments, not document bodies. I'm checking this with the Cloudant Dev team. If this is the case, then it's worth keeping (for attachments) but it isn't having the boost that you hoped it would.\r\n\r\nI'll report back."}}