I know it's shitty, but you need to pass a function that returns a stream into `RestAPI.Publications. createPublication(..` rather than the stream itself.

i.e.:
```javascript
RestAPI.Publications.createPublication(coenego.restContext, [generateRandomSourceId()], 'displayName A', 'journal article', date, authors, null, getFileStream, function(err, data) {
```