© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•2y ago•
8 replies
Hard@Work

This works fine for me in a Worker:

This works fine for me in a Worker:
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";

export default {
  async fetch(_, env) {
    const client = new S3Client({
      region: "auto",
      endpoint: env.R2_BUCKET_ENDPOINT,
      credentials: {
        accessKeyId: env.R2_ACCESS_KEY_ID,
        secretAccessKey: env.R2_SECRET_ACCESS_KEY,
      },
      forcePathStyle: true,
    });
    return Response.json(
      await client.send(
        new GetObjectCommand({
          Bucket: "somebucket",
          Key: "somefile",
        })
      )
    );
  },
};
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";

export default {
  async fetch(_, env) {
    const client = new S3Client({
      region: "auto",
      endpoint: env.R2_BUCKET_ENDPOINT,
      credentials: {
        accessKeyId: env.R2_ACCESS_KEY_ID,
        secretAccessKey: env.R2_SECRET_ACCESS_KEY,
      },
      forcePathStyle: true,
    });
    return Response.json(
      await client.send(
        new GetObjectCommand({
          Bucket: "somebucket",
          Key: "somefile",
        })
      )
    );
  },
};
What exactly are you running?
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

ok this has to be a bug in `workerd`
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-discussions
3y ago
Billing for using websockets in Worker
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-discussions
6mo ago
Workers should be fine - got anymore
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-discussions
17mo ago