Vercel Blob
Vercel Blob allows you to upload and serve files through a global network through unique and unguessable URLs.Vercel Blob is a great solution for storing blobs that need to be frequently read. Here are some examples suitable for Vercel Blob:
You can create and manage your Vercel Blob stores from your account dashboard. You can scope your Vercel Blob stores to your Hobby account or team, and connect them to as many projects as you want.
To get started, see our quickstart.
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 projects
- Vercel Blob URLs are publicly accessible, created with an unguessable random id, and immutable
- To add to or remove from the content of a Blob store, a valid token is required
- Making a blob private is planned in an upcoming release
There are two ways to upload files to Vercel Blob:
- Server uploads: This is the most common way to upload files. The file is first sent to your server and then to Vercel Blob. It's straightforward to implement, but you are limited to the request body your server can handle. Which in case of a Vercel-hosted website is 4.5 MB. This means you can't upload files larger than 4.5 MB on Vercel when using this method.
- Client uploads: This is a more advanced solution for when you need to upload larger files. The file is securely sent directly from the client (a browser for example) to Vercel Blob. This requires a bit more work to implement, but it allows you to upload files up to 500 MB.
You can also upload files larger than 4.5 MB directly from a script or server code, as long as the file isn't received from a Vercel-hosted website. An example of that would be a server-side fetch()
request streaming the response to Vercel Blob.
Vercel Blob URLs, although publicly accessible, are unique and hard to guess. They are composed of a unique store id, a pathname and a unique random blob id generated when the blob is created.
Headers that enhance security by preventing unauthorized downloads, blocking external content from being embedded, and protecting against malicious file type manipulation, are enforced on each blob. They are:
Content-Disposition
:attachment; filename="filename.extension"
Content-Security-Policy
:default-src "none"
x-frame-options
:DENY
x-content-type-options
:nosniff
Vercel Blobs are cached for one year in browsers, and 5 minutes in edge cache. This means any changes may take up to 5 minutes to reflect on Vercel's servers and be available to your users.
You can configure this caching behavior by using the cacheControlMaxAge
option on the put()
method.
The minimum value is 0 second for browser and edge cache. The maximum value is 5 minutes for edge cache and unlimited for browse cache.
The query string on the blob URL is part of the cache key, which means you can bypass the cache by adding a unique query string to the URL when necessary.
Note: when serving blobs from the edge cache, we do no not increment the number of basic operations, we only bill for the used bandwidth.
Vercel Blob supports range requests for partial downloads. This means you can download only a portion of a blob, here are examples:
curl https://1sxstfwepd7zn41q.public.blob.vercel-storage.com/range-requests.txt
# 0123456789
# First 5 bytes
curl -r 0-4 https://1sxstfwepd7zn41q.public.blob.vercel-storage.com/range-requests.txt
# 01234
# Last 5 bytes
curl -r -5 https://1sxstfwepd7zn41q.public.blob.vercel-storage.com/range-requests.txt
# 56789
# Bytes 3-6
curl -r 3-6 https://1sxstfwepd7zn41q.public.blob.vercel-storage.com/range-requests.txt
# 3456
Was this helpful?