UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

27 lines (26 loc) 749 B
import { uploadDirect } from "@uploadcare/upload-client"; export async function uploadToUploadcare(files) { const publicKey = process.env.UPLOADCARE_PUBLIC_KEY; if (!publicKey) { throw new Error("Missing UPLOADCARE_PUBLIC_KEY"); } const results = []; for (const file of files) { const uploadResponse = await uploadDirect(file.data, { publicKey, store: "auto", fileName: file.name, contentType: file.type // onProgress: ({ isComputable, value }) => { // TODO: progress handling // }, }); results.push({ url: `https://ucarecdn.com/${uploadResponse.uuid}/`, uuid: uploadResponse.uuid, size: uploadResponse.size, name: file.name }); } return results; }