Skip to main content
FrogBot offers additional storage adapters to handle file uploads. These adapters allow you to store files in different locations, such as Amazon S3, Vercel Blob Storage, Google Cloud Storage, and more.

Configuration

Add a storage adapter to the root storage key. Without further configuration, it stores the files for FrogBot’s own upload collections:
List your own upload collections in collections. To keep one of FrogBot’s collections on local disk, set it to false:
Storage adapters run after every plugin, so an adapter also covers collections that plugins add.

Multiple adapters

FrogBot’s collections go to the first storage adapter in storage. To store one of them with a different adapter, list it in that adapter’s collections. Setting one to false only takes effect in the first adapter. Listing the same collection in two adapters stops FrogBot at startup with an error.
This app declares a files collection marked file: true. Here files uses Vercel Blob and frogbot-chat-assets uses S3.

Vercel Blob Storage

@frogbotai/storage-vercel-blob

Installation#vercel-blob-installation

Usage#vercel-blob-usage

  • FrogBot’s upload collections use the adapter automatically. Add your own upload collections to collections; each slug must match an existing upload collection.
  • Ensure you have BLOB_READ_WRITE_TOKEN set in your Vercel environment variables. This is usually set by Vercel automatically after adding blob storage to your project.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
  • When deploying to Vercel, server uploads are limited with 4.5MB. Set clientUploads to true to do uploads directly on the client.

Configuration Options#vercel-blob-configuration

Also accepts the shared options.

S3 Storage

@frogbotai/storage-s3

Installation#s3-installation

Usage#s3-usage

  • FrogBot’s upload collections use the adapter automatically. Add your own upload collections to collections; each slug must match an existing upload collection.
  • The config object can be any S3ClientConfig object (from @aws-sdk/client-s3). This is highly dependent on your AWS setup. Check the AWS documentation for more information.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
  • When deploying to Vercel, server uploads are limited with 4.5MB. Set clientUploads to true to do uploads directly on the client. You must allow CORS PUT method for the bucket to your website.
  • Configure signedDownloads (either globally or per-collection in collections) to use presigned URLs for files downloading. This can improve performance for large files (like videos) while still respecting your access control. Additionally, with signedDownloads.shouldUseSignedURL you can specify a condition whether FrogBot should use a presigned URL, if you want to use this feature only for specific files.
  • You can conditionally enable the adapter using the enabled option. For example, enabled: Boolean(process.env.S3_BUCKET) skips the adapter in local development when credentials are not set.

Configuration Options#s3-configuration

Also accepts the shared options. Entries in collections also accept signedDownloads, which overrides the adapter-level setting for that collection.

Signed downloads

For full S3ClientConfig options, see the AWS SDK Package and S3ClientConfig docs.

Using with Cloudflare R2 (via S3 API)#s3-r2

Cloudflare R2 exposes an S3-compatible API, so you can use @frogbotai/storage-s3 to connect to it. This is the recommended approach when deploying to Vercel, Netlify, or any Node.js environment. (The @frogbotai/storage-r2 adapter is for Cloudflare Workers only, where R2 is available as a native bucket binding.)
Required environment variables:
  • region: 'auto' — required by R2; standard AWS region values are not accepted
  • endpoint — your R2 S3 API endpoint from the Cloudflare dashboard. This is for uploads only — not for serving files
  • forcePathStyle: true — required for R2’s path-style bucket addressing
  • R2_PUBLIC_URL — your bucket’s public URL (either the *.r2.dev subdomain or a custom domain you’ve connected in Cloudflare). This is separate from the S3 API endpoint
  • disablePayloadAccessControl: true — bypasses FrogBot’s file proxy so URLs point directly to your public R2 domain

Azure Blob Storage

@frogbotai/storage-azure

Installation#azure-installation

Usage#azure-usage

  • FrogBot’s upload collections use the adapter automatically. Add your own upload collections to collections; each slug must match an existing upload collection.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
  • When deploying to Vercel, server uploads are limited with 4.5MB. Set clientUploads to true to do uploads directly on the client. You must allow CORS PUT method to your website.

Configuration Options#azure-configuration

Also accepts the shared options.

Google Cloud Storage

@frogbotai/storage-gcs

Installation#gcs-installation

Usage#gcs-usage

  • FrogBot’s upload collections use the adapter automatically. Add your own upload collections to collections; each slug must match an existing upload collection.
  • When enabled, this package will automatically set disableLocalStorage to true for each collection.
  • When deploying to Vercel, server uploads are limited with 4.5MB. Set clientUploads to true to do uploads directly on the client. You must allow CORS PUT method for the bucket to your website.

Configuration Options#gcs-configuration

Also accepts the shared options.

R2 Storage

@frogbotai/storage-r2 Use this adapter to store uploads in a Cloudflare R2 bucket via the Cloudflare Workers environment. If you’re connecting to R2 from a Node.js environment (Vercel, Netlify, etc.) using the S3-compatible API, see Using with Cloudflare R2 (via S3 API) instead.

Installation#r2-installation

Usage#r2-usage

  • FrogBot’s upload collections use the adapter automatically. Add your own upload collections to collections; each slug must match an existing upload collection.
  • Pass in the R2 bucket binding to the bucket option, this should be done in the environment where FrogBot is running (e.g. Cloudflare Worker).
  • You can conditionally enable the adapter with the enabled option.

Configuration Options#r2-configuration

Also accepts the shared options.

Shared storage options

Every storage adapter accepts these options, except where noted.

Collection-specific options

Prefix Composition

Storage adapters support two types of prefixes:
  • Collection prefix: Set at the adapter configuration level (e.g., prefix: 'media-folder')
  • Document prefix: Set per-document via the prefix field on the upload collection
New uploads are always stored beneath the collection prefix. useCompositePrefixes changes how a document prefix is read and stored:
  • Default (false): the document prefix is a full path. If it already starts with the collection prefix, it’s used as-is; otherwise it’s nested beneath the collection prefix, and the stored prefix field holds the combined path.
  • true: the document prefix is always relative. It’s joined to the collection prefix when the file key is built, and the stored prefix field holds only the document part.
Files uploaded before you change the setting keep the prefix they were stored with, for reads, URLs, and cleanup. This is useful when you want a base folder structure (collection prefix) while still allowing per-document organization (document prefix).

FrogBot Access Control

FrogBot ships with Access Control that runs even on statically served files. The same read Access Control property on your upload-enabled collections is used, and it allows you to restrict who can request your uploaded files. To preserve this feature, by default, storage adapters keep all file URLs exactly the same. Your file URLs won’t be updated to point directly to your cloud storage source, as in that case, FrogBot’s Access control will be completely bypassed and you would need public readability on your cloud-hosted files. Instead, all uploads will still be reached from the default /collectionSlug/staticURL/filename path. Storage adapters will “pass through” all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing Access Control in place. If this does not apply to you (your upload collection has read: () => true or similar) you can disable this functionality by setting disablePayloadAccessControl to true. When this setting is in place, the adapter will update your file URLs to point directly to your cloud host. For a concrete example, see Using with Cloudflare R2 (via S3 API).

Conditionally Enabling/Disabling

Use the adapter’s enabled property to conditionally enable or disable cloud storage. When disabled, local uploads remain available unless the collection disables local storage.