@vercel/blob
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -16,5 +16,6 @@ import { Readable } from 'node:stream'; | ||
interface BlobCommandOptions { | ||
token: string; | ||
token?: string; | ||
} | ||
interface PutCommandOptions extends BlobCommandOptions { | ||
access: 'public'; | ||
contentType?: string; | ||
@@ -24,3 +25,3 @@ contentEncoding?: string; | ||
} | ||
declare function put(pathname: string, body: string | Readable | Blob | ArrayBuffer | FormData | ReadableStream, options?: PutCommandOptions): Promise<PutBlobResult>; | ||
declare function put(pathname: string, body: string | Readable | Blob | ArrayBuffer | FormData | ReadableStream, options: PutCommandOptions): Promise<PutBlobResult>; | ||
declare function del(url: string, options?: BlobCommandOptions): Promise<void>; | ||
@@ -27,0 +28,0 @@ declare function head(url: string, options?: BlobCommandOptions): Promise<HeadBlobResult>; |
@@ -1,1 +0,1 @@ | ||
import{fetch as n}from"undici";async function l(e,o,t){return(await n(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}/${e}`,{method:"PUT",body:o,headers:{authorization:`Bearer ${r(t)}`},duplex:"half"})).json()}async function d(e,o){let t=new URL(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}`);t.searchParams.set("url",e),await n(t,{method:"DELETE",headers:{authorization:`Bearer ${r(o)}`}})}async function c(e,o){let t=new URL(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}`);t.searchParams.set("url",e);let s=await(await n(t,{method:"GET",headers:{authorization:`Bearer ${r(o)}`}})).json();return{...s,uploadedAt:new Date(s.uploadedAt)}}function r(e){if(e!=null&&e.token)return e.token;if(!process.env.BLOB_STORE_WRITE_TOKEN)throw new Error("BLOB_STORE_WRITE_TOKEN environment variable is not set. Please set it to your write token.");return process.env.BLOB_STORE_WRITE_TOKEN}export{d as del,c as head,l as put}; | ||
import{fetch as r}from"undici";async function l(e,o,t){if(!e)throw new Error("vercelBlob.put: pathname is required");if(!o)throw new Error("vercelBlob.put: body is required");if(!t||t.access!=="public")throw new Error('vercelBlob.put: access must be "public"');return(await r(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}/${e}`,{method:"PUT",body:o,headers:{authorization:`Bearer ${n(t)}`},duplex:"half"})).json()}async function c(e,o){let t=new URL(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}`);t.searchParams.set("url",e),await r(t,{method:"DELETE",headers:{authorization:`Bearer ${n(o)}`}})}async function d(e,o){let t=new URL(`${process.env.VERCEL_BLOB_API_URL||"https://blob-staging.vercel-storage.com"}`);t.searchParams.set("url",e);let s=await(await r(t,{method:"GET",headers:{authorization:`Bearer ${n(o)}`}})).json();return{...s,uploadedAt:new Date(s.uploadedAt)}}function n(e){if(e!=null&&e.token)return e.token;if(!process.env.BLOB_STORE_WRITE_TOKEN)throw new Error("BLOB_STORE_WRITE_TOKEN environment variable is not set. Please set it to your write token.");return process.env.BLOB_STORE_WRITE_TOKEN}export{c as del,d as head,l as put}; |
{ | ||
"name": "@vercel/blob", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "The Vercel Blob JavaScript API client", | ||
@@ -5,0 +5,0 @@ "homepage": "https://vercel.com/blob", |
@@ -40,10 +40,10 @@ # 🍙 @vercel/blob | ||
options: { | ||
access: 'public', // mandatory, as we will provide private blobs in the future | ||
contentType?: string, // inferred from pathname | ||
access: 'public', // mandatory, as we will provide private blobs in the future | ||
contentType?: string, // inferred from pathname | ||
contentEncoding?: string, // text based files are gzipped by default when possible | ||
cacheControl?: string, // default to 1 year | ||
// `token` defaults to process.env.BLOB_STORE_WRITE_TOKEN on Vercel | ||
// and can be configured when you connect more stores to a project | ||
// `token` defaults to process.env.BLOB_STORE_WRITE_TOKEN on Vercel | ||
// and can be configured when you connect more stores to a project | ||
// or using Vercel Blob outside of Vercel | ||
token?: string, | ||
token?: string, | ||
}): Promise<{url: string}> {} | ||
@@ -82,3 +82,3 @@ ``` | ||
contentEncoding?: string; | ||
cacheControl?: '...'; | ||
cacheControl?: string; | ||
}> {} | ||
@@ -90,3 +90,3 @@ ``` | ||
- [Next.js App Router examples](./example/app/) | ||
- [https.get, axios, got, and CURL](./example/script.ts) | ||
- [https.get, axios, and got](./example/script.ts) | ||
@@ -156,3 +156,3 @@ ### Next.js App Router example. | ||
const blob = await vercelBlob.put(file.name, file); | ||
const blob = await vercelBlob.put(file.name, file, { access: 'public' }); | ||
@@ -159,0 +159,0 @@ return NextResponse.json(blob); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13316
51