-
-
Notifications
You must be signed in to change notification settings - Fork 969
Closed
Description
Current Behaviour
Hi, I am trying to upload the file stream to another server.
Please check the code below
const fd = new FormData({
readable: true
});
const stream = getFileStream();
fd.append('file', stream, {
filename: 'upload.txt',
});
await got.post('http://localhost:3001/upload', {
body: fd,
});
Hi, I am creating a file stream like the below snippet.
const getFileStream = () => {
const fileStream = createReadStream(filePath);
const passThrough = new PassThrough();
return fileStream.pipe(passThrough);
};
I have to use passthrough for some reasons.
If I do something like the above I get an error
'ERR_GOT_REQUEST_ERROR'
But if I change getFileStream function like below it works basically I am not using Passthrough
const getFileStream = () => {
const fileStream = createReadStream(filePath);
const passThrough = new PassThrough();
return fileStream;
};
If I do the same in Axios and node fetch it's working with passthrough.
Expected Behaviour:
It should upload the file
Node Version
v14.18.2
Metadata
Metadata
Assignees
Labels
No labels