kozy

1.0.1 • Public • Published

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 });
}

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i kozy

      Weekly Downloads

      0

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      4.42 kB

      Total Files

      5

      Last publish

      Collaborators

      • bahlulhasanli