{"action":"created","issue":{"url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/603","labels_url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/603/labels{/name}","comments_url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/603/comments","events_url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/603/events","html_url":"https://github.com/CollectionFS/Meteor-CollectionFS/issues/603","id":60795557,"number":603,"title":"Question: Creating a readStream from a stored Image does not work for me.","user":{"login":"johdirr","id":1122422,"avatar_url":"https://avatars.githubusercontent.com/u/1122422?v=3","gravatar_id":"","url":"https://api.github.com/users/johdirr","html_url":"https://github.com/johdirr","followers_url":"https://api.github.com/users/johdirr/followers","following_url":"https://api.github.com/users/johdirr/following{/other_user}","gists_url":"https://api.github.com/users/johdirr/gists{/gist_id}","starred_url":"https://api.github.com/users/johdirr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johdirr/subscriptions","organizations_url":"https://api.github.com/users/johdirr/orgs","repos_url":"https://api.github.com/users/johdirr/repos","events_url":"https://api.github.com/users/johdirr/events{/privacy}","received_events_url":"https://api.github.com/users/johdirr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-03-12T10:05:29Z","updated_at":"2015-07-22T09:17:18Z","closed_at":null,"body":"I need to manipulate a File that is already stored and i tried it like its documented at the [CollectionFS wiki](https://github.com/CollectionFS/Meteor-CollectionFS/wiki/Image-Manipulation#converting-a-file-already-stored).  \r\nThe Problem is that my app is unable to create a readStream for some reason. When the following code runs on the server\r\n\r\n    var fileObj = Images.findOne(\"<someId>\");\r\n    var readStream = fileObj.createReadStream('images');\r\n    \r\n    console.log(readStream);\r\n\r\nit prints out:\r\n\r\n    { _readableState: \r\n      { highWaterMark: 65536,\r\n        buffer: [],\r\n        length: 0,\r\n        pipes: null,\r\n        pipesCount: 0,\r\n        flowing: false,\r\n        ended: false,\r\n        endEmitted: false,\r\n       reading: false,\r\n       calledRead: false,\r\n       sync: true,\r\n       needReadable: false,\r\n       emittedReadable: false,\r\n       readableListening: false,\r\n       objectMode: false,\r\n       defaultEncoding: 'utf8',\r\n       ranOut: false,\r\n       awaitDrain: 0,\r\n       readingMore: false,\r\n       decoder: null,\r\n       encoding: null },\r\n     readable: true,\r\n     domain: null,\r\n     _events: { end: [Function] },\r\n     _maxListeners: 10,\r\n     path: '<path/to/my/project>/.meteor/local/cfs/files/images/images-5mFyJC5uJuCea9QFz-hsinhsiang199015770189004.jpg',\r\n     fd: null,\r\n     flags: 'r',\r\n     mode: 438,\r\n     start: undefined,\r\n     end: undefined,\r\n     autoClose: true,\r\n     pos: undefined,\r\n     safeOn: [Function],\r\n     safeOnce: [Function] \r\n    }\r\n\r\nAs you can see, the `buffer` is empty and the `length` is `0`.\r\n\r\n**But if I execute the exact same code** within the `meteor shell` then i get the following:\r\n\r\n    { _readableState: \r\n      { highWaterMark: 65536,\r\n        buffer: [ \r\n          <Buffer ff d8 ff e1 23 86 45 78 69 66 00 00 4d 4d 00 2a 00 00 00 08 00 0c 01 00 00 03 00 00 00 01 05 00 00 00 01 01 00 03 00 00 00 01 03 c0 00 00 01 02 00 03 00 ...>,\r\n          <Buffer 2a 23 21 09 d3 12 99 27 83 20 42 40 b9 85 50 51 5c bc 72 5c 90 35 44 d1 39 d5 5f c9 00 4a 2e e2 8c 8d 28 3e a8 3d 72 a2 6b ea 8b d7 32 9a ef 4a fa 00 8b ...> \r\n        ],\r\n        length: 118865,\r\n        pipes: null,\r\n        pipesCount: 0,\r\n        flowing: false,\r\n        ended: false,\r\n        endEmitted: false,\r\n        reading: false,\r\n        calledRead: true,\r\n        sync: false,\r\n        needReadable: false,\r\n        emittedReadable: true,\r\n        readableListening: false,\r\n        objectMode: false,\r\n        defaultEncoding: 'utf8',\r\n        ranOut: false,\r\n        awaitDrain: 0,\r\n        readingMore: false,\r\n        decoder: null,\r\n        encoding: null },\r\n      readable: true,\r\n      domain: null,\r\n      _events: { end: [Function] },\r\n      _maxListeners: 10,\r\n      path: '<path/to/my/project>/.meteor/local/cfs/files/images/images-5mFyJC5uJuCea9QFz-hsinhsiang199015770189004.jpg',\r\n      fd: 34,\r\n      flags: 'r',\r\n      mode: 438,\r\n      start: undefined,\r\n      end: undefined,\r\n      autoClose: true,\r\n      pos: undefined,\r\n      safeOn: [Function],\r\n      safeOnce: [Function] \r\n    }\r\n\r\nThe `buffer` is not empty and the `length` is not `0`. I have no clue what I'm doin wrong. Any Ideas?\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/comments/123633779","html_url":"https://github.com/CollectionFS/Meteor-CollectionFS/issues/603#issuecomment-123633779","issue_url":"https://api.github.com/repos/CollectionFS/Meteor-CollectionFS/issues/603","id":123633779,"user":{"login":"illmat","id":3836583,"avatar_url":"https://avatars.githubusercontent.com/u/3836583?v=3","gravatar_id":"","url":"https://api.github.com/users/illmat","html_url":"https://github.com/illmat","followers_url":"https://api.github.com/users/illmat/followers","following_url":"https://api.github.com/users/illmat/following{/other_user}","gists_url":"https://api.github.com/users/illmat/gists{/gist_id}","starred_url":"https://api.github.com/users/illmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/illmat/subscriptions","organizations_url":"https://api.github.com/users/illmat/orgs","repos_url":"https://api.github.com/users/illmat/repos","events_url":"https://api.github.com/users/illmat/events{/privacy}","received_events_url":"https://api.github.com/users/illmat/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T09:17:18Z","updated_at":"2015-07-22T09:17:18Z","body":"Seems to be a timing problem. Try with \r\n```javascript\r\nvar fileObj = Images.findOne(\"<someId>\");\r\nvar readStream = fileObj.createReadStream('images');\r\nMeteor._sleepForMs(1);\r\nconsole.log(readStream);\r\n```"}}