forwardemail / forwardemail/superagent

superagent.get doesn't behave as readable stream with AWS.S3.upload

Open
#1,463 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to use `superagent.get` with `S3.upload`, but it appears `.get` doesn't return readable stream, so upload never starts.

```
const request = require('superagent');
const AWS = require('aws-sdk');

const S3 = new AWS.S3({ ... });
const stream = request.get(nonExistentUrl);

S3.upload({ Bucket: 'my-bucket', Key: 'file.txt', Body: stream}, (...args) => {
console.log(...args);
});
```

I am trying to test with faulty URL that returns `404`, and I expect upload to fail.
But it appears upload is never started unless I call `stream.end()`, then 404 error is printed to console.

This behavior is consistent in v3 and v4.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.