1.0.1 • Published 1 year ago

kozy v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

kozy

Next 13 FormData image upload tool via API route

npm i kozy
yarn add kozy
pnpm add kozy

It is very easy to use. After installing the package, create a route called upload under the api folder and add the following code.

export async function POST(req: NextRequest, res: NextResponse) {
  const form: any = await req.formData();
  const file = form.get('avatar');

  const uploaded: any = await UploadImage({
    file,
    folder: 'uploads',
    name: `hello_world`,
    size: '2 MB',
  });

  return NextResponse.json({ data: uploaded.file, isSuccess: true });
}
1.0.1

1 year ago

1.0.0

1 year ago