question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multipart form data

See original GitHub issue

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! : )

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
kitsonkcommented, May 27, 2020

I’ve started working on this, but it is fairly complex. I am not convinced the std multi part really is a good interface, so I am going to come up with something a better better I think.

3reactions
kitsonkcommented, May 25, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does enctype='multipart/form-data' mean? - Stack Overflow
When you make a POST request, you have to encode the data that forms the body of the request in some way. HTML...
Read more >
Multipart/form-data - OutSystems
OutSystems does not support multipart/form-data. However, the Multipart/form-data plugin allows to achieve it. Read this nicely documented ...
Read more >
Multipart (Form Data) Format - MuleSoft Documentation
DataWeave supports Multipart subtypes, in particular form-data . These formats enable you to handle several different data parts in a single payload, ...
Read more >
Multipart Requests - Swagger
Multipart requests combine one or more sets of data into a single body, separated by ... File uploads typically use the multipart/form-data media...
Read more >
What is multipart form data? How to handle it with ... - YouTube
Today we discuss what is multipart form data, when it is used, and the types of API calls it will be needed form....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found