Skip to content
Dashboard

Private storage for Vercel Blob, now available in public beta

, , Priyanka Jindal
vercel blob create-store [name] --access private

pnpm add @vercel/blob@2.3

upload.ts
import { put } from '@vercel/blob';
export async function POST(request: Request) {
// Your auth goes here: await authRequest(req)
const filename = request.nextUrl.searchParams.get('filename');
const blob = await put(filename, request.body, {
access: 'private',
});
return Response.json(blob);
}

retrieve.ts
import { get } from '@vercel/blob';
export async function GET(req: Request) {
// Your auth goes here: await authRequest(req)
const filename = request.nextUrl.searchParams.get('filename');
const { stream, blob } = await get(filename, {
access: "private",
});
return new Response(stream, {
headers: {
"Content-Type": blob.contentType,
},
});
}