Movatterモバイル変換


[0]ホーム

URL:


Choose a framework to optimize documentation to:

    Vercel Blob

    Vercel Blob is available onall plans

    Those with theowner, member, developer role can access this feature

    Vercel Blob is a great solution for storingblobs that need to be frequently read. Here are some examples suitable for Vercel Blob:

    • Files that are programmatically uploaded or generated at build time, for display and download such as avatars, screenshots, cover images and videos
    • Large files such as videos and audios to take advantage of the global network
    • Files that you would normally store in an external file storage solution like Amazon S3. With your project hosted on Vercel, you can readily access and manage these files with Vercel Blob

    Stored files are referred to as "blobs" once they're in the storage system,following cloud storage terminology.

    import { put }from'@vercel/blob';constblob=awaitput('avatar.jpg', imageFile, {  access:'public',});

    You can create and manage your Vercel Blob stores from youraccount dashboard or theVercel CLI. You can create blob stores in any of the 19regions to optimize performance and meet data residency requirements. You can scope your Vercel Blob stores to your Hobby team orteam, and connect them to as many projects as you want.

    To get started, see theserver-side, orclient-side quickstart guides. Or visit the full API reference for theVercel Blob SDK.

    If you'd like to know whether or not Vercel Blob can be integrated into your workflow, it's worth knowing the following:

    • You can have one or more Vercel Blob stores per Vercel account
    • You can use multiple Vercel Blob stores in one Vercel project
    • Each Vercel Blob store can be accessed by multiple Vercel projectsVercel Blob URLs are publicly accessible, but you can make themunguessable.
    • To add to or remove from the content of a Blob store, a validtoken is required

    If you need to transfer your blob store from one project to another project in the same or different team, reviewTransferring your store.

    Each Blob is served with acontent-disposition header. Based on the MIME type of the uploaded blob, it is either set toattachment (force file download) orinline (can render in a browser tab).This is done to prevent hosting specific files on@vercel/blob like HTML web pages. Your browser will automatically download the blob instead of displaying it for these cases.

    Currentlytext/plain,text/xml,application/json,application/pdf,image/*,audio/* andvideo/* resolve to acontent-disposition: inline header.

    All other MIME types default tocontent-disposition: attachment.

    If you need a blob URL that always forces a download you can use thedownloadUrl property on the blob object. This URL always has thecontent-disposition: attachment header no matter its MIME type.

    import { list }from'@vercel/blob';exportdefaultasyncfunctionPage() {constresponse=awaitlist();return (    <>      {response.blobs.map((blob)=> (        <akey={blob.pathname}href={blob.downloadUrl}>          {blob.pathname}        </a>      ))}    </>  );}

    Alternatively the SDK exposes a helper function calledgetDownloadUrl that returns the same URL.

    When you request a blob URL using a browser, the content is cached in two places:

    1. Your browser's cache
    2. Vercel'sedge cache

    Both caches store blobs for up to 1 month by default to ensure optimal performance when serving content. While both systems aim to respect this duration, blobs may occasionally expire earlier.

    Vercel will cache blobs up to512 MB. Bigger blobs will always be served from the origin (your store).

    You can customize the caching duration using thecacheControlMaxAge option in theput() andhandleUpload methods.

    The minimum configurable value is 60 seconds (1 minute). This represents the maximum time needed for our cache to update content behind a blob URL. For applications requiring faster updates, consider using aVercel function instead.

    When you delete or update (overwrite) a blob, the changes may take up to 60 seconds to propagate through our edge cache. However, browser caching presents additional challenges:

    • While our edge cache can update to serve the latest content, browsers will continue serving the cached version
    • To force browsers to fetch the updated content, add a unique query parameter to the blob URL:
    <imgsrc="https://1sxstfwepd7zn41q.public.blob.vercel-storage.com/blob-oYnXSVczoLa9yBYMFJOSNdaiiervF5.png?v=123456"/>

    For more information about updating existing blobs, see theOverwriting blobs section.

    For optimal performance and to avoid caching issues, consider treating blobs as immutable objects:

    • Instead of updating existing blobs, create new ones with different pathnames (or useaddRandomSuffix: true option)
    • This approach avoids unexpected behaviors like outdated content appearing in your application

    There are still valid use cases for mutable blobs with shorter cache durations, such as a single JSON file that's updated every 5 minutes with a top list of sales or other regularly refreshed data. For these scenarios, set an appropriatecacheControlMaxAge value and be mindful of caching behaviors.

    By default, Vercel Blob prevents you from accidentally overwriting existing blobs by using the same pathname twice. When you attempt to upload a blob with a pathname that already exists, the operation will throw an error.

    To explicitly allow overwriting existing blobs, you can use theallowOverwrite option:

    constblob=awaitput('user-profile.jpg', imageFile, {  access:'public',  allowOverwrite:true,// Enable overwriting an existing blob with the same pathname});

    This option is available in these methods:

    • put()
    • In client uploads via theonBeforeGenerateToken() function

    Overwriting blobs can be appropriate for certain use cases:

    1. Regularly updated files: For files that need to maintain the same URL but contain updated content (like JSON data files or configuration files)
    2. Content with predictable update patterns: For data that changes on a schedule and where consumers expect updates at the same URL

    When overwriting blobs, be aware that due tocaching, changes won't be immediately visible. The minimum time for changes to propagate is 60 seconds, and browser caches may need to be explicitly refreshed.

    If you want to avoid overwriting existing content (recommended for most use cases), you have two options:

    1. UseaddRandomSuffix: true: This automatically adds a unique random suffix to your pathnames:
    constblob=awaitput('avatar.jpg', imageFile, {  access:'public',  addRandomSuffix:true,// Creates a pathname like 'avatar-oYnXSVczoLa9yBYMFJOSNdaiiervF5.jpg'});
    1. Generate unique pathnames programmatically: Create unique pathnames by adding timestamps, UUIDs, or other identifiers:
    consttimestamp=Date.now();constblob=awaitput(`user-profile-${timestamp}.jpg`, imageFile, {  access:'public',});

    Vercel Blob delivers content through a specialized network optimized for static assets:

    • Region-based distribution: Content is served from 18 regional hubs strategically located around the world
    • Optimized for non-critical assets: Well-suited for content "below the fold" that isn't essential for initial page rendering metrics like First Contentful Paint (FCP) or Largest Contentful Paint (LCP)
    • Cost-optimized for large assets: 3x more cost-efficient thanFast Data Transfer on average
    • Great for media delivery: Ideal for large media files like images, videos, and documents

    WhileFast Data Transfer provides city-level, ultra-low latency, Blob Data Transfer prioritizes cost-efficiency for larger assets where ultra-low latency isn't essential.

    Blob Data Transfer fees apply only to downloads (outbound traffic), not uploads. Seepricing documentation for details.

    Upload charges depend on your implementation method:

    While Vercel Blob URLs can be designed to be unique and unguessable (when usingaddRandomSuffix: true), they can still be indexed by search engines under certain conditions:

    • If you link to blob URLs from public webpages
    • If you embed blob content (images, PDFs, etc.) in indexed content
    • If you share blob URLs publicly, even in contexts outside your application

    By default, Vercel Blob does not provide arobots.txt file or other indexing controls. This means search engines like Google may discover and index your blob content if they find links to it.

    If you want to prevent search engines from indexing your blob content, you need to upload arobots.txt file directly to your blob store:

    1. Go to yourStorage page and select your blob store
    2. Upload arobots.txt file to the root of your blob store with appropriate directives

    Examplerobots.txt content to block all crawling of your blob store:

    User-agent: *Disallow: /

    If your blob content has already been indexed by search engines:

    1. Verify your website ownership inGoogle Search Console
    2. Upload arobots.txt file to your blob store as described above
    3. Use the "Remove URLs" tool in Google Search Console to request removal

    You can create Blob stores in any of the 19regions. Use the region selector in the dashboard at blob store creation time, or use theCLI with the--region option.

    Select a region close to your customers and functions to minimize upload time. Region selection also helps meet data regulatory requirements. Vercel Blobpricing is regionalized, so check the pricing for your selected region.

    You cannot change the region once the store is created.

    Simple operations in Vercel Blob are specific read actions counted for billing purposes:

    • When thehead() method is called to retrieve blob metadata
    • When a blob is accessed by its URL and it's a cache MISS

    A cache MISS occurs when the blob is accessed for the first time or when its previously cached version has expired. Note that blob URL access resulting in a cache HIT does not count as a Simple Operation.

    Advanced operations in Vercel Blob are write, copy, and listing actions counted for billing purposes:

    • When theput() method is called to upload a blob
    • When theupload() method is used for client-side uploads
    • When thecopy() method is called to copy an existing blob
    • When thelist() method is called to list blobs in your store

    Using the Vercel Blob file browser in your dashboard will count as operations. Each time you refresh the blob list, upload files through the dashboard, or view blob details, these actions use the same API methods that count toward your usage limits and billing.

    Common dashboard actions that count as operations:

    • Refreshing the file browser: Useslist() to display your blobs
    • Uploading files via dashboard: Usesput() for each file uploaded
    • Viewing blob details: May trigger additional API calls
    • Navigating folders: Useslist() with different prefixes

    If you notice unexpected increases in your operations count, check whether team members are browsing your blob store through the Vercel dashboard.

    Formultipart uploads, multiple advanced operations are counted:

    • One operation when starting the upload
    • One operation for each part uploaded
    • One operation for completing the upload

    Delete operations using thedel() are free of charge. They are considered advanced operations foroperation rate limits but not for billing.

    Vercel Blob measures your storage usage by taking snapshots of your blob store size every 15 minutes and averages these measurements over the entire month to calculate your GB-month usage. This approach accounts for fluctuations in storage as blobs are added and removed, ensuring you're only billed for your actual usage over time, not peak usage.

    The Vercel dashboard displays two metrics:

    • Latest value: The most recent measurement of your blob store size
    • Monthly average: The average of all measurements throughout the billing period (this is what you're billed for)

    Example:

    1. Day 1: Upload a 2GB file → Store size: 2GB
    2. Day 15: Add 1GB file → Store size: 3GB
    3. Day 25: Delete 2GB file → Store size: 1GB

    Month end billing:

    • Latest value: 1GB
    • Monthly average: ~2GB (billed amount)

    If no changes occur in the following month (no new uploads or deletions), each 15-minute measurement would consistently show 1 GB. In this case, your next month's billing would be exactly 1 GB/month, as your monthly average would equal your latest value.

    Vercel Blob supportsmultipart uploads for large files, which provides significant advantages when transferring substantial amounts of data.

    Multipart uploads work by splitting large files into smaller chunks (parts) that are uploaded independently and then reassembled on the server. This approach offers several key benefits:

    • Improved upload reliability: If a network issue occurs during upload, only the affected part needs to be retried instead of restarting the entire upload
    • Better performance: Multiple parts can be uploaded in parallel, significantly increasing transfer speed
    • Progress tracking: More granular upload progress reporting as each part completes

    We recommend using multipart uploads for files larger than 100 MB. Both theput() andupload() methods handle all the complexity of splitting, uploading, and reassembling the file for you.

    For billing purposes, multipart uploads count as multiple advanced operations:

    • One operation when starting the upload
    • One operation for each part uploaded
    • One operation for completing the upload

    This approach ensures reliable handling of large files while maintaining the performance and efficiency expected from modern cloud storage solutions.

    Vercel Blob leveragesAmazon S3 as its underlying storage infrastructure, providing industry-leading durability and availability:

    • Durability: Vercel Blob offers 99.999999999% (11 nines) durability. This means that even with one billion objects, you could expect to go a hundred years without losing a single one.
    • Availability: Vercel Blob provides 99.99% (4 nines) availability in a given year, ensuring that your data is accessible when you need it.

    These guarantees are backed byS3's robust architecture, which includes automatic replication and error correction mechanisms.

    Vercel Blob has folders support to organize your blobs:

    constblob=awaitput('folder/file.txt','Hello World!', { access:'public' });

    The pathfolder/file.txt creates a folder namedfolder and a blob namedfile.txt. To list all blobs within a folder, use thelist function:

    constlistOfBlobs=awaitlist({  cursor,  limit:1000,  prefix:'folder/',});

    You don't need to create folders. Upload a file with a path containing a slash/, and Vercel Blob will interpret the slashes as folder delimiters.

    In the Vercel Blob file browser on the Vercel dashboard, any pathname with a slash/ is treated as a folder. However, these are not actual folders like in a traditional file system; they are used for organizing blobs in listings and the file browser.

    Blobs are returned inlexicographical order by pathname (not creation date) when usinglist(). Numbers are treated as characters, sofile10.txt comes beforefile2.txt.

    Sort by creation date: Include timestamps in pathnames:

    consttimestamp=newDate().toISOString().split('T')[0];// YYYY-MM-DDawaitput(`reports/${timestamp}-quarterly-report.pdf`, file, {  access:'public',});

    Use prefixes for search: Consider lowercase pathnames for consistent matching:

    awaitput('user-uploads/avatar.jpg', file, { access:'public' });constuserUploads=awaitlist({ prefix:'user-uploads/' });

    For complex sorting, sort results client-side usinguploadedAt or other properties.

    Last updated on June 26, 2025

    Previous
    Security / Two-factor Enforcement
    Next
    Server Uploads

    Was this helpful?

    supported.
    On this page

    [8]ページ先頭

    ©2009-2025 Movatter.jp