Does form-data support fs-capacitor stream?
See original GitHub issueI’m using apollo-upload-server for uploading files to the server. In my resolver function, I have a stream
. What I want to do is pass this stream as a file (multipart/form-data) to another server. I use promise-request (that under the hood use form-data to achieve that. Code look like below:
import * as request from 'request-promise';
async upload(_, { file }) {
const { stream } = await file;
return await request.post({
uri: `${NLP_API_BASE}/upload`,
formData: {
datasheet: stream
}
});
}
But I’m getting an error :
RequestError: Error: socket hang up at new RequestError (/Users/igat/Code/projects/botsupply-oracle-backend/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/Users/igat/Code/projects/botsupply-oracle-backend/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/Users/igat/Code/projects/botsupply-oracle-backend/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/Users/igat/Code/projects/botsupply-oracle-backend/node_modules/request/request.js:185:22) at emitOne (events.js:121:20) at Request.emit (events.js:211:7) at Request.onRequestError (/Users/igat/Code/projects/botsupply-oracle-backend/node_modules/request/request.js:877:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at Socket.socketOnEnd (_http_client.js:423:9) at emitNone (events.js:111:20) at Socket.emit (events.js:208:7) at endReadableNT (_stream_readable.js:1056:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
And as I understand apollo-upload-server
use fs-capacitor to deal with a stream. Does form-data support fs-capacitor stream? What is wrong with my code?
Guys any ideas? I’m really stuck.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:22
Top GitHub Comments
@rheaditi I tested a few different approaches and ended up with this resolver for a file upload with
apollo-upload-server@7.0.0
.Maybe this is helpful to you! I haven’t tested with newer versions of
apollo-upload-server
yet.It works for me with additional headers (using node-fetch)