POST /api/files/upload
Upload files to Vercel Blob storage. Currently supports image files (JPEG and PNG) up to 5MB.Authentication
Requires authenticated session. Returns401 if not authenticated.
Request
This endpoint expects amultipart/form-data request with a file field.
The file to upload. Must be a JPEG or PNG image under 5MB.
Validation rules
Maximum 5MB (5,242,880 bytes)
Must be
image/jpeg or image/pngResponse
Returns a blob metadata object on success.Public URL of the uploaded file
Path of the file in blob storage
MIME type of the uploaded file
Content disposition header value
Example
Error responses
- No file uploaded
- File size exceeds 5MB
- File type is not JPEG or PNG
User is not authenticated
- Upload to Vercel Blob failed
- Failed to process request
Implementation
The endpoint uses Vercel Blob’sput function with public access. Files are stored with their original filename.
app/(chat)/api/files/upload/route.ts
To support additional file types, update the
FileSchema validation in the route handler.Related
Chat interface
Learn how files are used in chat messages
Data persistence
Learn about Vercel Blob storage configuration