sanity-plugin-r2-files
Version:
Store Sanity media files in Cloudflare R2 Bucket
37 lines (36 loc) • 1.23 kB
JavaScript
import { ApiIcon, EyeClosedIcon, FolderIcon, PinIcon } from '@sanity/icons';
export const schemaConfig = {
title: 'Media file hosted in Cloudflare R2 Bucket',
customFields: ['fileKey', 'baseUrl'],
};
export const credentialsFields = [
{
name: 'workerUrl',
title: 'Cloudflare Worker URL',
description: 'URL of the Cloudflare Worker that handles the signed URL requests for uploading files to the R2 Bucket.',
icon: PinIcon,
type: 'url',
validation: (Rule) => Rule.required(),
},
{
name: 'folder',
title: 'Folder',
description: "Folder to store files inside the R2 Bucket. If none provided, will upload files to the R2 Bucket's root. Creates one if it doesn't exist.",
icon: FolderIcon,
type: 'string',
},
{
name: 'url',
title: 'Public URL',
description: 'Public Url of the bucket. Either enable R2.dev Subdomain or configure custom domain.',
icon: ApiIcon,
type: 'url',
},
{
name: 'secret',
title: 'Secret',
description: 'Secret for validating the signed URL request (optional)',
icon: EyeClosedIcon,
type: 'string',
},
];