profile
viewpoint

Ask questionsSupport multipart form data

Sorry! I am learning English. So... I mean this That's the request header: image That's the request body: image The type is multipart/form-data This my router:

export default router => {
  router.get('/getList', async ctx => {
    ctx.response.body = 'get getList';
  });
  router.post('/getList', async ctx => {
    const result = await ctx.request.body({
      contentTypes: {
        json: ['application/json'],
        form: ['multipart/form-data'],
        text: ['application/json']
      }
    });
    if(result.type === 'form'){
      console.log(result.value.get('name'));
    }
    ctx.response.body = result.value;
  });
}

But what I got is null, I consoled this value with for...of, the output is

[
  "----------------------------387832257824253405999369
Content-Disposition: form-data; name",
  ""group_id"

1659592055145472
----------------------------387832257824253405999369
Content-Dispos..."
]

I know this is the boundary, but how to deal whit this file type? Thank you very much! : )

oakserver/oak

Answer questions kitsonk

@lengfangbing Yes, dealing with multi-part form data is something oak should do without the user being aware of how it is dealt with.

useful!

Related questions

No questions were found.
Github User Rank List