menu

ZEIT

Our mission is to make cloud computing as easy and accessible as mobile computing. You can find our Next.js community here.

Channels
Team

POST multipart/form-data into micro

November 28, 2019 at 2:21am
The ZEIT community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →

POST multipart/form-data into micro

November 28, 2019 at 2:21am
I'm recieving a POST request into micro that carries multipart/form-data in it. In my example, it's of ContentType image/png
I can't figure out how to turn that back into a working file. I'm using the buffer within micro, eg:
import { buffer } from 'micro';
...
const body = await buffer(req);
But if I write the resulting buffer to the file-system, the size is the same as the posted data, but the image does not open.
Is there some kind of encoding settings, or other body-parsing I need to be doing?
Thanks!

November 28, 2019 at 9:01pm
I'm resorting to using busboy but would like to avoid adding another dependency if Micro just has this capability within it (aka the buffer helper or like) and I'm just not seeing how to use it properly.
Thanks everyone.
  • reply
  • like
private
This channel has been archived