Actions9
Overview
This node enables uploading objects (files or binary data) to Cloudflare R2, a scalable object storage service compatible with the S3 API. It is useful for workflows that require storing files in cloud storage, such as backups, media hosting, or data archiving.
Typical use cases include:
- Uploading user-generated content or logs to an R2 bucket.
- Automating file uploads from other systems or APIs.
- Storing processed data outputs for later retrieval or sharing.
For example, you can upload images, documents, or any binary data from previous workflow steps into a specified R2 bucket and key (path).
Properties
| Name | Meaning |
|---|---|
| Bucket Name | The name of the Cloudflare R2 bucket where the object will be uploaded. Must be globally unique. |
| Object Key | The key (path) within the bucket under which the object will be stored. |
| Binary Property | The name of the binary property in the input item that contains the data to upload. |
| Create Bucket If Not Exists | Boolean flag indicating whether to create the bucket if it does not already exist. |
| Additional Options | Collection of optional settings for the upload: |
| - Cache Control | Specifies caching behavior along the request/reply chain. |
| - Content Disposition | Specifies presentational information for the object (e.g., attachment; filename). |
| - Content Encoding | Specifies what content encodings have been applied to the object. |
| - Metadata | A set of key-value pairs to store as metadata with the object. |
| - Storage Class | The storage class for the object. Currently supports "Standard". |
Output
The node outputs JSON objects for each uploaded item containing:
success: Boolean indicating if the upload succeeded.bucket: The bucket name where the object was uploaded.key: The object key (path) used for the upload.etag: The ETag header returned by R2, representing the object's checksum or version identifier.
No binary output is produced by this operation.
Dependencies
- Requires valid Cloudflare API credentials configured with R2 S3-compatible access keys and endpoint.
- Uses AWS SDK v3 S3 client configured to communicate with Cloudflare R2 endpoints.
- The node expects the binary data to be available in the specified binary property of the input items.
- No additional environment variables are required beyond the Cloudflare API credential setup.
Troubleshooting
- Missing or invalid credentials: The node throws an error if the R2 Access Key ID, Secret Access Key, or endpoint URL is missing or invalid. Ensure your Cloudflare API credentials are correctly configured with "R2 S3-Compatible" authentication mode.
- Bucket does not exist: If the bucket does not exist and
Create Bucket If Not Existsis false, the upload will fail. Enable this option to auto-create buckets. - Object key conflicts or invalid characters: Ensure the object key is a valid path string without unsupported characters.
- Binary property not found: The node requires the specified binary property to contain the data buffer. Verify the property name matches the input data.
- Network or permission errors: Check network connectivity and that the API token has sufficient permissions for bucket and object operations.
Common error messages include:
"R2 credentials are missing or invalid."— Check API key and secret."Cannot delete bucket 'X': Bucket must be completely empty before deletion."— Remove all objects before deleting a bucket.- HTTP status errors from R2 API responses with descriptive messages.
Links and References
- Cloudflare R2 Documentation
- Cloudflare API Tokens
- AWS SDK for JavaScript v3 S3 Client
- n8n Documentation on Custom Nodes
Summary of execute() method logic for Resource=Object, Operation=Upload
- Retrieves input data items.
- For each item:
- Reads parameters: bucket name, object key, binary property name, and additional options.
- If
createBucketIfNotExistsis true, attempts to check if the bucket exists; if not, creates it. - Retrieves the binary data buffer from the specified binary property.
- Prepares headers including content type from the binary mime type.
- Sends a PUT request to the R2 endpoint at
/{bucket}/{objectKey}with the binary data as body. - Includes optional headers for cache control, content disposition, content encoding, metadata, and storage class if provided.
- On success, returns JSON with success status, bucket, key, and etag.
- On failure, throws an error or returns error info if continueOnFail is enabled.
This implementation uses the AWS SDK's S3Client configured with Cloudflare R2 credentials and endpoint, signing requests with AWS Signature V4.