Using superagent as a writable stream
See original GitHub issueHi there,
I am trying to upload some files to OpenStack ObjectStorage, creating a read stream from a file and piping into request.
var request = require('superagent');
var req = request.post(base);
var stream = fs.createReadStream('/path/to/file');
req.on('response', function(res) {
console.log('Success');
});
stream.pipe(req);
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 nothing
Using .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 😄
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Using superagent as a writable stream · Issue #1250 - GitHub
I am trying to upload some files to OpenStack ObjectStorage, creating a read stream from a file and piping into request. var request...
Read more >Piping readable stream using superagent - node.js
Create a superagent instance with URL, method and HTTP headers you want for uploading,; Listen to data events on the incoming file stream,...
Read more >superagent.SuperAgentRequest.pipe JavaScript and Node.js ...
Best JavaScript code snippets using superagent. ... imgsDir + fileName); let req = request.get(img); let stream = req.pipe(write); logger.debug('>>>> start ...
Read more >readable-stream - npm.io
This package is a mirror of the streams implementations in Node.js 18.9.0. Full documentation may be found on the Node.js website. If you...
Read more >superagent - Bountysource
var request = require('superagent'); var req = request.post(base); var stream = fs.createReadStream('/path/to/file'); req.on('response', function(res) { console ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
attached is the plot file I’m using
Yep this is still an issue ^
FWIW I have a workaround that seems to be working as expected: