Skip to main content

Storage Bubble

Cloudflare R2 storage operations for file management

Quick Start

import { StorageBubble } from '@bubblelab/bubble-core';
import { CredentialType } from '@bubblelab/shared-schemas';
const result = await new StorageBubble({
operation: 'getUploadUrl',
credentials: {
[CredentialType.CLOUDFLARE_R2_ACCESS_KEY]: process.env.CLOUDFLARE_R2_ACCESS_KEY as string,
},
}).action();

Operation Details

getUploadUrl

operation 'getUploadUrl' required
Generate presigned upload URL
bucketName string required
Name of the R2 bucket
fileName string required
Original filename for the upload
accountId string
Cloudflare Account ID - can be provided via credentials
region string
AWS region for R2 storage (defaults to auto)
expirationMinutes number
URL expiration time in minutes
contentType string
Content type for uploads
userId string
User ID for secure file isolation
credentials Record<CredentialType,string>
Object mapping credential types to values (injected at runtime)

getFile

operation 'getFile' required
Generate presigned download URL
bucketName string required
Name of the R2 bucket
fileName string required
Name of the file to retrieve
accountId string
Cloudflare Account ID - can be provided via credentials
region string
AWS region for R2 storage (defaults to auto)
expirationMinutes number
URL expiration time in minutes
userId string
User ID for secure file isolation
credentials Record<CredentialType,string>
Object mapping credential types to values (injected at runtime)

deleteFile

operation 'deleteFile' required
Delete file from bucket
bucketName string required
Name of the R2 bucket
fileName string required
Name of the file to delete
accountId string
Cloudflare Account ID - can be provided via credentials
region string
AWS region for R2 storage (defaults to auto)
credentials Record<CredentialType,string>
Object mapping credential types to values (injected at runtime)

updateFile

operation 'updateFile' required
Update/replace file content
bucketName string
fileName string required
Name of the file to update
accountId string
Cloudflare Account ID - can be provided via credentials
region string
AWS region for R2 storage (defaults to auto)
contentType string
Content type for uploads
fileContent string required
Base64 encoded file content or raw text content
credentials Record<CredentialType,string>
Object mapping credential types to values (injected at runtime)

getMultipleUploadUrls

operation 'getMultipleUploadUrls' required
Generate multiple presigned upload URLs for PDF + page images
bucketName string required
Name of the R2 bucket
pdfFileName string required
Original filename for the PDF
pageCount number required
Number of pages to generate upload URLs for
accountId string
Cloudflare Account ID - can be provided via credentials
region string
AWS region for R2 storage (defaults to auto)
expirationMinutes number
URL expiration time in minutes
userId string
User ID for secure file isolation
credentials Record<CredentialType,string>
Object mapping credential types to values (injected at runtime)