Closed jchariot closed 4 years ago
If you use the Chrome network inspector to look at the outgoing GraphQL request, in the request body in the multipart string do the file field names look correct?
If you use the Chrome network inspector to look at the outgoing GraphQL request, in the request body in the multipart string do the file field names look correct?
My code is on node.js, and I am using Postman to do a post request to node.js. All of this is on localhost.
For additional information, GraphQL returned this 500 Internal Server Error and this:
{ "errors": [ { "message": "Cannot read property 'statuscode' of null" } ] }
statuscode is one of the things I requested as a returning value, but it seems GraphQL went haywire and couldn't return anything properly.
Chrome network inspector to look at the outgoing GraphQL request
Sorry, I am not sure how to do this. Would you mind give me some pointers?
In node.js app, I logged out the request.body.variables.file1 out:
app.use(
entry_url,
graphqlUploadExpress({ maxFileSize: 4000000, maxFiles: 10 }),
graphqlHTTP((request) => {
console.log( request.body.variables.file1 )
return {
schema: inputSchema,
context: { startTime: Date.now(), bodyQuery: request.body.query},
originalContext: request },
graphiql: true,
extensions,
};
}),
);
and I got the following:
Upload {
resolve: [Function],
reject: [Function],
promise:
Promise {
{ filename: 's�\r.pdf',
mimetype: 'application/pdf',
encoding: '7bit',
createReadStream: [Function: createReadStream] } },
file:
{ filename: 's�\r.pdf',
mimetype: 'application/pdf',
encoding: '7bit',
createReadStream: [Function: createReadStream] } }
Personally I don't use Postman, but it seems you can easily open a network inspector this way:
It would be good to figure out if the filenames are being sent correctly from the client. If they are not, then we know the problem is on the client.
Personally I don't use Postman, but it seems you can easily open a network inspector this way:
It would be good to figure out if the filenames are being sent correctly from the client. If they are not, then we know the problem is on the client.
Upon further inspection. We created another tiny app to test this, and the tiny app could send files with non-English name to the node.js app without any issue. Therefore, Postman (v7.34.0) is at fault here.
I am using GraphQLUpload. Everything works ok, but whenever I upload a file that contains non-English characters in the file's name, the app seems to . For example, I got a file named "平仮名.pdf". When I uploaded it in, this is what I got from console.log above:
So "平仮名.pdf" became "s�\r.pdf" . This occurs with other languages as well. How do I fix this issue?