File stream is null
See original GitHub issueFor some reason, my server is returning an empty stream instead of the file.
Here’s the client’s request:
-----------------------------81678640518046430391178682890
Content-Disposition: form-data; name="operations"
{"operationName":null,"variables":{"file":null},"query":"mutation ($file: Upload!) {\n uploadUserImage(file: $file)\n}\n"}
-----------------------------81678640518046430391178682890
Content-Disposition: form-data; name="map"
{"1":["variables.file"]}
-----------------------------81678640518046430391178682890
Content-Disposition: form-data; name="1"; filename="signature.jpg"
Content-Type: image/jpeg
******** Whole Lot of data ************
-----------------------------81678640518046430391178682890--
On the server
async (parent, { file }) => {
const { createReadStream, filename, mimetype, encoding } = await file;
const stream = createReadStream();
stream.on("data", data => {
console.log("DATA**********************");
console.log(data);
});
stream.on("readable", () => {
console.log(stream.read());
});
}
Nothing gets outputted. When I send stream’s data as response it returns as null.
Interestingly, filename, mimetype and encoding all are populated.
I am using apollo-server-express as my server.
Here’s the schema for the method
uploadUserImage(file: Upload!): String
Will really appreciate your help on this. Thanks 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Why the variable FileStream writer is null? - Stack Overflow
Setting the parameter, a local variable named writer in the LocalDirectorySettings() method, has no effect on the other local variable, ...
Read more >Stream.Null Field (System.IO) - Microsoft Learn
Use Null to redirect output to a stream that will not consume any operating system resources. When the methods of Stream that provide...
Read more >Listening to ItemAdded File Stream is NUll
I'm currently listening to the ItemAdded event using a RER for a DocumentLibrary, this so far works perfectly. However I have an issue...
Read more >Problem getting data from filestream C# - CodeProject
I'm passing the file path to create file-stream and when I'm trying to fetch the data from the FileStream, the data is null....
Read more >Demonstrate the use of the Null stream as a bit bucket
Demonstrate the use of the Null stream as a bit bucket : Stream Null « File Stream « C# / C Sharp ·...
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 Free
Top 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
You should be promisifying and awaiting the file upload like in the example:
https://github.com/jaydenseric/apollo-upload-examples/blob/master/api/resolvers.mjs#L21
Give that a go and see if you still have the issue.
Can someone help to solve the same in python using Django? Thanks in advance!