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
- Input Schema
- Output Schema
operation'getUploadUrl' required- Generate presigned upload URL
bucketNamestring required- Name of the R2 bucket
fileNamestring required- Original filename for the upload
accountIdstring- Cloudflare Account ID - can be provided via credentials
regionstring- AWS region for R2 storage (defaults to auto)
expirationMinutesnumber- URL expiration time in minutes
contentTypestring- Content type for uploads
userIdstring- User ID for secure file isolation
credentialsRecord<CredentialType,string>- Object mapping credential types to values (injected at runtime)
operation'getUploadUrl' required- Generate presigned upload URL
successboolean required- Whether the operation was successful
uploadUrlstring- Presigned upload URL
fileNamestring- Secure filename generated for the upload
contentTypestring- Content type of the file
errorstring required- Error message if operation failed
getFile
- Input Schema
- Output Schema
operation'getFile' required- Generate presigned download URL
bucketNamestring required- Name of the R2 bucket
fileNamestring required- Name of the file to retrieve
accountIdstring- Cloudflare Account ID - can be provided via credentials
regionstring- AWS region for R2 storage (defaults to auto)
expirationMinutesnumber- URL expiration time in minutes
userIdstring- User ID for secure file isolation
credentialsRecord<CredentialType,string>- Object mapping credential types to values (injected at runtime)
operation'getFile' required- Generate presigned download URL
successboolean required- Whether the operation was successful
downloadUrlstring- Presigned download URL
fileUrlstring- Direct file access URL
fileNamestring- Name of the file
fileSizenumber- File size in bytes
contentTypestring- Content type of the file
lastModifiedstring- Last modified timestamp in ISO format
errorstring required- Error message if operation failed
deleteFile
- Input Schema
- Output Schema
operation'deleteFile' required- Delete file from bucket
bucketNamestring required- Name of the R2 bucket
fileNamestring required- Name of the file to delete
accountIdstring- Cloudflare Account ID - can be provided via credentials
regionstring- AWS region for R2 storage (defaults to auto)
credentialsRecord<CredentialType,string>- Object mapping credential types to values (injected at runtime)
operation'deleteFile' required- Delete file from bucket
successboolean required- Whether the operation was successful
fileNamestring- Name of the deleted file
deletedboolean- Whether the file was successfully deleted
errorstring required- Error message if operation failed
updateFile
- Input Schema
- Output Schema
operation'updateFile' required- Update/replace file content
bucketNamestringfileNamestring required- Name of the file to update
accountIdstring- Cloudflare Account ID - can be provided via credentials
regionstring- AWS region for R2 storage (defaults to auto)
contentTypestring- Content type for uploads
fileContentstring required- Base64 encoded file content or raw text content
credentialsRecord<CredentialType,string>- Object mapping credential types to values (injected at runtime)
operation'updateFile' required- Update/replace file content and generate a new secure filename for the file
successboolean required- Whether the operation was successful
fileNamestring- Secure filename for the updated file (different from the original filename)
updatedboolean- Whether the file was successfully updated
contentTypestring- Content type of the updated file
errorstring required- Error message if operation failed
getMultipleUploadUrls
- Input Schema
- Output Schema
operation'getMultipleUploadUrls' required- Generate multiple presigned upload URLs for PDF + page images
bucketNamestring required- Name of the R2 bucket
pdfFileNamestring required- Original filename for the PDF
pageCountnumber required- Number of pages to generate upload URLs for
accountIdstring- Cloudflare Account ID - can be provided via credentials
regionstring- AWS region for R2 storage (defaults to auto)
expirationMinutesnumber- URL expiration time in minutes
userIdstring- User ID for secure file isolation
credentialsRecord<CredentialType,string>- Object mapping credential types to values (injected at runtime)
operation'getMultipleUploadUrls' required- Generate multiple presigned upload URLs for PDF + page images
successboolean required- Whether the operation was successful
pdfUploadUrlstring- Presigned upload URL for PDF
pdfFileNamestring- Secure filename for PDF
pageUploadUrlsobject[]- Array of upload URLs for page images
errorstring required- Error message if operation failed