Cloudflare R2
Interact with Cloudflare R2 object storage. Upload, download, manage files and buckets. Supports batch operations, multipart uploads, and can be used as a tool by AI Agents.
Actions15
- Bucket Actions
- Object Actions
- Batch Operations Actions
Overview
The node enables managing Cross-Origin Resource Sharing (CORS) settings for Cloudflare R2 buckets. Specifically, the "Set CORS" operation allows users to configure CORS rules on a specified bucket, defining which origins, HTTP methods, and headers are permitted when accessing resources in that bucket from web browsers. This is essential for enabling secure cross-domain requests to your R2 storage.
Common scenarios include:
- Allowing a web application hosted on one domain to access resources stored in an R2 bucket on another domain.
- Configuring fine-grained CORS policies to restrict or allow specific HTTP methods or headers.
- Setting cache durations for preflight OPTIONS requests to optimize performance.
Practical example:
- A developer wants to enable their frontend app at
https://example.comto perform GET and POST requests to files in an R2 bucket. They would use this node to set CORS rules allowing originhttps://example.com, methods GET and POST, and specify allowed headers likeContent-Type.
Properties
| Name | Meaning |
|---|---|
| Bucket Name | The unique name of the R2 bucket to configure CORS for. |
| CORS Rules | Configuration of one or more CORS rules, each specifying: |
- Allowed Origins: Comma-separated list of origins allowed to make cross-origin requests (e.g., *). |
|
| - Allowed Methods: HTTP methods permitted for CORS requests. Options: GET, POST, PUT, DELETE, HEAD. | |
| - Allowed Headers: Comma-separated list of HTTP headers allowed in requests. | |
| - Max Age (seconds): Duration for which preflight request results can be cached by browsers. |
Output
The output JSON contains:
success: Boolean indicating if the CORS configuration update was successful.message: Confirmation string, e.g.,"CORS configuration updated".
No binary data is output by this operation.
Example output JSON:
{
"success": true,
"message": "CORS configuration updated"
}
Dependencies
- Requires an API key credential for authenticating with Cloudflare R2.
- Uses internal utility functions to validate bucket names and interact with the Cloudflare R2 API.
- No additional external dependencies beyond standard n8n credentials and Cloudflare R2 API access.
Troubleshooting
- Invalid bucket name format: If the bucket name does not meet Cloudflare R2 naming requirements, the node throws an error. Ensure the bucket name is valid and unique.
- Malformed CORS rules: Incorrectly formatted origins, methods, or headers may cause errors or unexpected behavior. Use comma-separated strings for origins and headers, and select allowed methods from provided options.
- API authentication errors: Ensure the API key credential is correctly configured and has permissions to modify bucket CORS settings.
- Empty or missing CORS rules: Setting empty rules will clear the CORS configuration; verify intended behavior before applying.