Unable to pass `request` upload
Closed this issue · 7 comments
If you set { upload: { file: request('some-url') } }
(with the request
library), then this error happens:
/home/julian/dev/transloadit/node-sdk/node_modules/into-stream/index.js:74
const chunk = input.slice(0, size);
^
TypeError: input.slice is not a function
at Class.reader [as _from] (/home/julian/dev/transloadit/node-sdk/node_modules/into-stream/index.js:74:23)
at Class._read (/home/julian/dev/transloadit/node-sdk/node_modules/from2/index.js:68:10)
at Class.Readable.read (/home/julian/dev/transloadit/node-sdk/node_modules/readable-stream/lib/_stream_readable.js:443:10)
at resume_ (/home/julian/dev/transloadit/node-sdk/node_modules/readable-stream/lib/_stream_readable.js:790:12)
It works if the request
stream is piped to a simple PassThrough
, and that then passed to the sdk
Ohh it’s not ‘upload’ but ‘uploads’. We could add some validation of the json document.
See example here: (it’s got, not request tho)
Sorry that was a typo, I'm indeed passing uploads
. I assume this is something specific to the request
library
Ohh ok i will look into that. I guess we should have a unit test for request also since many ppl are using that too
It has long been deprecated so personally I don't think we need to support it really, but it would be nice to have a different error
Seems like is-stream
does not detect this stream as readable because it's an old type of stream (sindresorhus/is-stream#9)
Could be fixed by just checking for isStream instead of also checking for readable, but since request is deprecated and it can be worked around with passthrough, then I will instead throw a better error