Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R2] Adding workflow for using Rclone to upload to R2 #21227

Open
wants to merge 3 commits into
base: production
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/content/docs/r2/objects/upload-objects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,64 @@ sidebar:
order: 1
---

import { Steps, Tabs, TabItem } from "~/components"

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

## Upload objects via Rclone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have example for rclone. Should we reference it instead?
https://developers.cloudflare.com/r2/examples/rclone/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the example could do with clearer instructions. I'll link the example, but might not remove what I've written for now (the example doesn't capture info on how to configure Rclone). Does that sound sensible?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we then add these steps to that example and refer it here? The example already contains relevant links and calls out things that are important. We can also separate the Upload and retrieve objects into separate sections.
If we still want to show the code, we can have the code block and for other instructions send the user to the examples page.


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 using their official documentation - [Install Rclone](https://rclone.org/install/).

### 1. Configure Rclone by running `rclone config`

First, configure your Rclone with the following settings.

<Steps>
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.
</Steps>

### 2. Upload files to R2

Upload your files to R2.

```sh
# 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.

```sh
rclone ls r2:bucket_name
```

Refer to our [Rclone example](/r2/examples/rclone/).

## Upload objects via the Cloudflare dashboard

To upload objects to your bucket from the Cloudflare dashboard:

<Steps>
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) 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**.
</Steps>

You will receive a confirmation message after a successful upload.

Expand All @@ -38,3 +86,9 @@ Upload complete.
```

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

:::note
Use Rclone if you wish to upload multiple objects to R2.

Wrangler's `object put` command only allows you to upload one object at a time.
:::