Skip to content
Cloudflare Docs

Download objects

You can download objects from R2 using the dashboard, Workers API, S3 API, or command-line tools.

Download via dashboard

  1. In the Cloudflare dashboard, go to the R2 object storage page.

    Go to Overview
  2. Select your bucket.

  3. Locate the object you want to download.

  4. Select ... for the object and click Download.

Download via Workers API

Use R2 bindings in Workers to download objects:

TypeScript
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
const object = await env.MY_BUCKET.get("image.png");
return new Response(object.body);
},
} satisfies ExportedHandler<Env>;

For complete documentation, refer to Workers API.

Download via S3 API

Use S3-compatible SDKs to download objects. You'll need your account ID and R2 API token.

TypeScript
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
const S3 = new S3Client({
region: "auto", // Required by SDK but not used by R2
// Provide your Cloudflare account ID
endpoint: `https://<ACCOUNT_ID>.r2.cloudflarestorage.com`,
// Retrieve your S3 API credentials for your R2 bucket via API tokens (see: https://developers.cloudflare.com/r2/api/tokens)
credentials: {
accessKeyId: '<ACCESS_KEY_ID>',
secretAccessKey: '<SECRET_ACCESS_KEY>',
},
});
const response = await S3.send(
new GetObjectCommand({
Bucket: "my-bucket",
Key: "image.png",
}),
);

Refer to R2's S3 API documentation for all S3 API methods.

Presigned URLs

For client-side downloads where users download directly from R2, use presigned URLs. Your server generates a temporary download URL that clients can use without exposing your API credentials.

  1. Your application generates a presigned GET URL using an S3 SDK
  2. Send the URL to your client
  3. Client downloads directly from R2 using the presigned URL

For details on generating and using presigned URLs, refer to Presigned URLs.

Download via Wrangler

Use Wrangler to download objects. Run the r2 object get command:

Terminal window
wrangler r2 object get test-bucket/image.png

The file will be downloaded into the current working directory. You can also use the --file flag to set a new name for the object as it is downloaded, and the --pipe flag to pipe the download to standard output (stdout).