question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot open downloaded file

See original GitHub issue

Here’s the case:

var supertest = require('supertest');
var fs = require('fs');
var express = require('express');
var app = express();

app.get('/image', function (req, res) {
  fs.createReadStream('src/test/expected/igloo.jpg').pipe(res);
})

var request = supertest(app);

request.get('/image')
  .end(function(err, res) {
    fs.writeFileSync('/tmp/test_superagent', res.text)
    console.log('end!', res)
  })

I’d like to save the image in my tmp directory. The problem is that I can’t open it. I try different encoding but the result is always the same. Is there anything I miss?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hallascommented, Apr 7, 2014

not sure but try to add .buffer() to your request chain like so:

request.get(...).buffer().end(fn)

0reactions
aweijnitzcommented, Sep 17, 2014

FYI. Fixed the test and the parser and sent a pull request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Open Downloads in Windows 10? Try These ... - MiniTool
When you can't open Downloads folder, perhaps there are some corrupted system files. In Windows, the built-in tool – System File Checker, can...
Read more >
[Solved] Can't Open Downloads Folder in Windows 10
The first thing to do when you see a not responding/inaccessible Downloads folder is to run the System File Checker. The purpose of...
Read more >
Downloads Folder Not Responding on Windows 10? Fix It Now!
Sometimes, corrupted system files or bad sectors on Windows system drive may cause hard drives, folders, or files inaccessible. Therefore, ...
Read more >
Can't open a Google file or folder - Android
If a file won't open, a few things could be wrong: You don't have permission to view the file. You're signed in to...
Read more >
Cannot open downloaded files - Microsoft Community
Outdated application, application error, file damage, and permission related issues are a few of the possible reasons why you are experiencing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found