New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using superagent as a writable stream #1250
Comments
We don't support piping to the request. You have to use |
@pornel Are you say piping is an "unsupported" feature of Using |
Oh, sorry. I wasn't aware of that :D If there's a test for it then I guess it should work, but obviously I'm not any better informed about what's going on than you.
|
Yeap this would work. The weird thing is that the piping works for node // app.js
'use strict';
var request = require('superagent');
var req = request
.post('https://requestb.in/example')
.on('response', function(res) {
console.log(res.status);
console.log(res.text);
})
.on('error', function(err) {
console.log(err);
});
process.stdin.pipe(req); $ node app.js < file.txt
$ node app.js < example.png # Fails for node `4.8.3`, superagent `3.5.2` Something must have changed in Node's |
Perhaps my issue is related. I'm trying to stream an image into CouchDB. It works fine with Request, but fails with superagent. I wrote a test and put it into node/pipe.js as follows:
It hangs after reading just two chunks. Same behavior on my app (reads two chunks and hangs)
node version 7.10.0 |
my fork with the test case details: https://github.com/jmarca/superagent/tree/bug/stream_image |
Is this still an issue? |
I’ll fire it up and see. Is been quite a while! |
Yep this is still an issue ^ FWIW I have a workaround that seems to be working as expected: new Promise((resolve, reject) => {
const upload = request.post(url)
const req = upload.request()
pipeline(stream, req, (err) => {
if (err) {
upload.abort()
return reject(err)
}
upload.end((err, res) => {
if (err) return reject(err)
return resolve(res.body)
})
})
}) |
Hi there,
I am trying to upload some files to OpenStack ObjectStorage, creating a read stream from a file and piping into request.
The above works for text files, but for images nothing happens and the request times out.
Update: I added listeners for the
'error'
event on both readable and writable streams but there is nothingUsing
.attach()
"works" but the uploaded file now has all the multipart form metadata i.e. the image is "corrupted".Versions
Node v4.8.3
Superagent 3.5.2
Any ideas? I feel like I am missing something obvious here, thanks in advance 😄
The text was updated successfully, but these errors were encountered: