Skip to content
Cloudflare Docs

Upload objects

You can upload objects to your bucket from the Cloudflare dashboard or using the Wrangler.

Upload objects via Rclone

Rclone is a command-line tool which manages files on cloud storage. You can use Rclone to upload objects to R2. To use Rclone, install it onto your machine:

To install on a Mac device, install with brew.

Terminal window
brew install rclone

1. Configure Rclone by running rclone config

First, configure your Rclone with the following settings.

  1. Create new remote by selecting n.
  2. Select a name for the new remote. For example, use r2.
  3. Select the Amazon S3 Compliant Storage Providers storage type.
  4. Select Cloudflare R2 storage for the provider.
  5. Select whether you would like to enter AWS credentials manually, or get it from the runtime environment.
  6. Enter the AWS Access Key ID.
  7. Enter AWS Secret Access Key (password).
  8. Select the region to connect to (optional).
  9. Select the S3 API endpoint.

2. Upload files to R2

Upload your files to R2.

Terminal window
# Upload a single file.
# Specify the target bucket with this syntax: <remote name>:<bucket name>
# In this example, <remote name> is 'r2'
rclone copy /path/to/local/file.txt r2:bucket_name
# Upload everything in a directory
rclone copy /path/to/local/folder r2:bucket_name

3. Verify successful upload

Verify that your files have been uploaded by listing the objects stored in the destination R2 bucket.

Terminal window
rclone ls r2:bucket_name

Upload objects via the Cloudflare dashboard

To upload objects to your bucket from the Cloudflare dashboard:

  1. Log in to the Cloudflare dashboard and select R2.
  2. From the R2 page in the dashboard, locate and select your bucket.
  3. Select Upload.
  4. Choose to either drag and drop your file into the upload area or select from computer.

You will receive a confirmation message after a successful upload.

Upload objects via Wrangler

To upload a file to R2, call put and provide a name (key) for the object, as well as the path to the file via --file:

Terminal window
wrangler r2 object put test-bucket/dataset.csv --file=dataset.csv
Creating object "dataset.csv" in bucket "test-bucket".
Upload complete.

You can set the Content-Type (MIME type), Content-Disposition, Cache-Control and other HTTP header metadata through optional flags.