{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-storage-node/issues/608","repository_url":"https://api.github.com/repos/Azure/azure-storage-node","labels_url":"https://api.github.com/repos/Azure/azure-storage-node/issues/608/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-storage-node/issues/608/comments","events_url":"https://api.github.com/repos/Azure/azure-storage-node/issues/608/events","html_url":"https://github.com/Azure/azure-storage-node/issues/608","id":478152079,"node_id":"MDU6SXNzdWU0NzgxNTIwNzk=","number":608,"title":"Blob: Additional bytes added to binary data when retrieving from store","user":{"login":"dhensby","id":563596,"node_id":"MDQ6VXNlcjU2MzU5Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/563596?v=4","gravatar_id":"","url":"https://api.github.com/users/dhensby","html_url":"https://github.com/dhensby","followers_url":"https://api.github.com/users/dhensby/followers","following_url":"https://api.github.com/users/dhensby/following{/other_user}","gists_url":"https://api.github.com/users/dhensby/gists{/gist_id}","starred_url":"https://api.github.com/users/dhensby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhensby/subscriptions","organizations_url":"https://api.github.com/users/dhensby/orgs","repos_url":"https://api.github.com/users/dhensby/repos","events_url":"https://api.github.com/users/dhensby/events{/privacy}","received_events_url":"https://api.github.com/users/dhensby/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"jiacfan","id":13328178,"node_id":"MDQ6VXNlcjEzMzI4MTc4","avatar_url":"https://avatars3.githubusercontent.com/u/13328178?v=4","gravatar_id":"","url":"https://api.github.com/users/jiacfan","html_url":"https://github.com/jiacfan","followers_url":"https://api.github.com/users/jiacfan/followers","following_url":"https://api.github.com/users/jiacfan/following{/other_user}","gists_url":"https://api.github.com/users/jiacfan/gists{/gist_id}","starred_url":"https://api.github.com/users/jiacfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiacfan/subscriptions","organizations_url":"https://api.github.com/users/jiacfan/orgs","repos_url":"https://api.github.com/users/jiacfan/repos","events_url":"https://api.github.com/users/jiacfan/events{/privacy}","received_events_url":"https://api.github.com/users/jiacfan/received_events","type":"User","site_admin":false},"assignees":[{"login":"jiacfan","id":13328178,"node_id":"MDQ6VXNlcjEzMzI4MTc4","avatar_url":"https://avatars3.githubusercontent.com/u/13328178?v=4","gravatar_id":"","url":"https://api.github.com/users/jiacfan","html_url":"https://github.com/jiacfan","followers_url":"https://api.github.com/users/jiacfan/followers","following_url":"https://api.github.com/users/jiacfan/following{/other_user}","gists_url":"https://api.github.com/users/jiacfan/gists{/gist_id}","starred_url":"https://api.github.com/users/jiacfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiacfan/subscriptions","organizations_url":"https://api.github.com/users/jiacfan/orgs","repos_url":"https://api.github.com/users/jiacfan/repos","events_url":"https://api.github.com/users/jiacfan/events{/privacy}","received_events_url":"https://api.github.com/users/jiacfan/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2019-08-07T21:40:39Z","updated_at":"2019-08-14T05:49:23Z","closed_at":"2019-08-14T05:49:23Z","author_association":"NONE","body":"### Which service(blob, file, queue, table) does this issue concern?\r\n\r\nblob\r\n\r\n### Which version of the SDK was used?\r\n\r\n2.10.3\r\n\r\n### What's the Node.js/Browser version?\r\n\r\n10.6.0\r\n\r\n### What problem was encountered?\r\n\r\nWhen retrieving binary data (PNG images in this case) the following error is thrown:\r\n\r\n```\r\nError: An incorrect number of bytes was read from the connection. The connection may have been closed.\r\n    at BlobService._validateLengthAndMD5 (./node_modules/azure-storage/lib/services/blob/blobservice.core.js:5422:28)\r\n    at processResponseCallback (./node_modules/azure-storage/lib/services/blob/blobservice.core.js:1879:12)\r\n    at Request.processResponseCallback [as _callback] (./node_modules/azure-storage/lib/common/services/storageserviceclient.js:329:13)\r\n    at Request.self.callback (./node_modules/request/request.js:185:22)\r\n    at Request.emit (events.js:182:13)\r\n    at Request.<anonymous> (./node_modules/request/request.js:1161:10)\r\n    at Request.emit (events.js:182:13)\r\n    at IncomingMessage.<anonymous> (./node_modules/request/request.js:1083:12)\r\n    at Object.onceWrapper (events.js:273:13)\r\n    at IncomingMessage.emit (events.js:187:15)\r\n```\r\n\r\n### Steps to reproduce the issue?\r\n\r\n```js\r\nconst { promisify } = require('utils');\r\nconst { createBlobService } = require('azure-storage');\r\n\r\nconst blobSvc = createBlobService();\r\nconst createBlob = promisify(blobSvc.createBlockBlobFromText.bind(blobSvc));\r\nconst getBlob = promisify(blobSvc.getBlobToText.bind(blobSvc));\r\n\r\nasync function example() {\r\n    await createBlob('container', 'test.png', Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), {\r\n        contentSettings: {\r\n            contentType: 'application/json',\r\n        },\r\n    });\r\n    await getBlob('container', 'test.png'); // this will throw\r\n}\r\n```\r\n\r\n### Have you found a mitigation/solution?\r\n\r\nUse `getBlobToStream` instead. I understand that the blob is not text data, but if we can send and successfully store buffers representing non-text based data, why can we not retrieve it with the corresponding API. The response from the server seems to be corrupted in the server side as the text data gets 2 additional bytes added to it.\r\n\r\nMy debugging has found that the data response appears to be correct, but it has some additional trailing whitespace, which adds 2 additional bytes causing the length comparison to fail. Is there a better way to get a `Buffer` returned?"},"comment":{"url":"https://api.github.com/repos/Azure/azure-storage-node/issues/comments/521110585","html_url":"https://github.com/Azure/azure-storage-node/issues/608#issuecomment-521110585","issue_url":"https://api.github.com/repos/Azure/azure-storage-node/issues/608","id":521110585,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMTExMDU4NQ==","user":{"login":"jiacfan","id":13328178,"node_id":"MDQ6VXNlcjEzMzI4MTc4","avatar_url":"https://avatars3.githubusercontent.com/u/13328178?v=4","gravatar_id":"","url":"https://api.github.com/users/jiacfan","html_url":"https://github.com/jiacfan","followers_url":"https://api.github.com/users/jiacfan/followers","following_url":"https://api.github.com/users/jiacfan/following{/other_user}","gists_url":"https://api.github.com/users/jiacfan/gists{/gist_id}","starred_url":"https://api.github.com/users/jiacfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiacfan/subscriptions","organizations_url":"https://api.github.com/users/jiacfan/orgs","repos_url":"https://api.github.com/users/jiacfan/repos","events_url":"https://api.github.com/users/jiacfan/events{/privacy}","received_events_url":"https://api.github.com/users/jiacfan/received_events","type":"User","site_admin":false},"created_at":"2019-08-14T05:49:23Z","updated_at":"2019-08-14T05:49:23Z","author_association":"MEMBER","body":"Welcome discussion."}}
{"actor":{"display_login":"jiacfan"}}