vercel / micro

Asynchronous HTTP microservices
MIT License
10.59k stars 459 forks source link

How to read file from request? #434

Closed ozgreat closed 2 years ago

ozgreat commented 4 years ago

I wanna read a file from req, how can I do it? I don't wanna use micro-upload

OlliV commented 4 years ago

Just read or also write it to somewhere? There are various ways to read the body. For small files you could just do:

const {buffer} = require('micro');
...
const data = await buffer(req);
ozgreat commented 4 years ago

Just read or also write it to somewhere? There are various ways to read the body. For small files you could just do:

const {buffer} = require('micro');
...
const data = await buffer(req);

I wanna upload them to s3, but when I try to fs.writeFile(fileName, buf, err => console.log(err)) file is broken

rishabhjaishwal commented 4 years ago

Just want to know that anyone contribute to this repo

AubreyHewes commented 4 years ago

@ozgreat Micro is designed to be minimal and simplistic. You either need to write your own modules or use community modules.

You mention you do not want to use micro-upload ? You do not mention why you do not want to use this. Maybe as you expect a posted binary file?

I know that the currently published micro-upload is old and fails npm audits. The repo has a dependabot branch that alleviates this, easily defined in package.json..

For your use case...

leerob commented 2 years ago

Closing as stale - if you're open to contributing, I'd be happy to review a PR!