Request processed on POST but fails on PATCH


I am using this code to upload an image (direct streaming into the database):

request.multipart.file('file', {}, async function(file) {                                                                                    
  const fileContent = await getStream.buffer(                                                                                    
  photo.filecontents = fileContent                                                                                                           
  photo.type = `${file.type}/${file.subtype}`                                                                                                
await request.multipart.process()

This works perfectly fine when on a POST HTTP request in method.
However, on a PATCH HTTP request, the request always fails to process (I get a 500 HTTP code on the client side) in MyController.update().

I spent one hour debugging this, the PATCH request reaches the server, everything works except when I un-comment await request.multipart.process().

If I leave only this in the update() method of my controller, the request fails to process also:

request.multipart.field((name, value) => {                                                                                             value                                                                                                                        

Did I set the correct headers on my PATCH request? Yes, the same as I did for POST.

The request also fails to process on PATCH but runs smoothly on POST

Any hints as why this is not working?



Hi @virk Could you give me a hint where to investigate?
This is weird to me. I run the same code several times on isolated proof of concept projects and I had no issue except in this same project.



Hello @begueradj
can you post the content of your routes file?



The route is there. Everything else work in MyConroller.update() if I comment out this single line await request.multipart.process() (I can console.log( for instance)



@begueradj You said you receive a 500, which means it is a server error. Can you share the error response body that you receive?



try to put the code into a try/catch block to catch the error and see what it is

1 Like


The issue was a typo in the entry I set in processManually array.