Skip to content

BahlulHasanli/Kozy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Next 13 FormData image upload tool via API route

Resources

License

Stars

Watchers

Forks

Packages

No packages published