Getting createReadStream is not a function when uploading a file
See original GitHub issuegraphql-yoga: 1.18.2 react-native: 0.60.4 apollo-upload-client: 11.0.0
Hi there, after updating to 1.18 I can no longer upload files. I’m trying to upload a file using react-native and apollo-upload-client. Here’s what the mutation variable looks like on the client:
data: {
file: new ReactNativeFile({
uri,
type: typeForSaving,
name: 'photo-1.jpeg'
})
}
And here’s the server code:
Schema:
scalar Upload
type Mutation {
contentSingleUpload(data: ContentSingleUploadInput!): SingleUploadPayload!
}
input ContentSingleUploadInput {
file: Upload
}
Resolver:
async contentSingleUpload(parent, args, ctx, info) {
const fileResult = await processUpload(args.data.file)
}
const processUpload = async upload => {
const { createReadStream, filename, mimetype, encoding } = await upload
const stream = createReadStream()
...
}
The request fails with createReadStream is not a function
and when I try to look at args.data.file
I am seeing:
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:12
Top Results From Across the Web
Apollo Uploading Files, createReadStream is not a function
I tried to get this working for several days and getting now where. I do believe that that the client side is function...
Read more >How To Work with Files Using Streams in Node.js - DigitalOcean
Streams are an efficient way to handle files in Node.js. ... The createReadStream function creates a readable stream that emits events that ...
Read more >Can't upload a file from node.js to my route, getting empty ...
I am trying to upload a local file using NodeJs (the file is in the same directory as app.js) to my remote Laravel...
Read more >Tests in NodeJS hangs when doing a streaming client call and ...
It seems that in a test, a streaming client rpc does not play well when an operation like a file read when the...
Read more >fs.createReadStream is not a function : r/react - Reddit
To upload a file from browser to server, you need to use File API not fs.
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
while working on nexus solution was to call file inside file. try { const { file: { filename, mimetype, encoding, createReadStream }, } = file; console.log(“FIle 1”, file); let stream = createReadStream();
@stephensamra remplace
createReadStream
with juststream
and remove the lineconst stream = createReadStream()