moleculerjs/moleculer-apollo-server

File upload issue

dg92 opened this issue · 4 comments

dg92 commented

I am using https://altair.sirmuel.design (graphql IDE) to upload
this is how my action looks like

uploadFile: { graphql: { mutation: "uploadFile(file: Upload!, entityId: String!): Media", fileUploadArg: "file", }, async handler(ctx) { const fileChunks = []; for await (const chunk of ctx.params) { fileChunks.push(chunk); } const fileContents = Buffer.concat(fileChunks); // Do something with file contents return ctx.meta.$fileInfo; } }

Issue - i don't see readablestream in my ctx.params and my ctx.meta is an empty object, Error is object is not iterable , however, i can see that my ctx.params contains file obj with filename, mimetype, encoding that's it

There's not really enough information here for me to help you out. What is the error? How is your Media type defined? You're returning ctx.meta.$fileInfo which has very specific properties -- does that conform to your Media type?

dg92 commented

@shawnmcknight I am sry i edited it but did not save it, Media is just a datatype that has id(UUID) and publicURL(string) and i added the issue in the starting comment. For me the issue is i am missing the stream from the file Obj.

@shawnmcknight I am sry i edited it but did not save it, Media is just a datatype that has id(UUID) and publicURL(string) and i added the issue in the starting comment. For me the issue is i am missing the stream from the file Obj.

What version of moleculer-apollo-server are you running? The README for uploads (and the format you are using) is only relevant for version >= 0.3.0.

dg92 commented

@shawnmcknight yeah, I just checked I am using 0.2.0 version, thanks, i'm closing this for now.