File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
src/content/docs/r2/examples Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ pcx_content_type: Example
55
66import { Tabs , TabItem } from ' ~/components' ;
77
8- The following example shows how to authenticate against R2 using the S3 API and an API token.
8+ The following example shows how to authenticate against R2 using the S3 API and an API token.
99
1010:::note
1111For providing secure access to bucket objects for anonymous users, we recommend using [ pre-signed URLs] ( /r2/api/s3/presigned-urls/ ) instead.
@@ -39,14 +39,11 @@ export R2_BUCKET_NAME=your_bucket_name
3939 const SECRET_ACCESS_KEY = process .env .R2_SECRET_ACCESS_KEY ;
4040 const BUCKET_NAME = process .env .R2_BUCKET_NAME ;
4141
42- // Hash the secret access key
43- const hashedSecretKey = crypto .createHash (' sha256' ).update (SECRET_ACCESS_KEY ).digest (' hex' );
44-
4542 // Configure the S3 client for Cloudflare R2
4643 const s3Client = new AWS.S3 ({
4744 endpoint: ` https://${ ACCOUNT_ID } .r2.cloudflarestorage.com` ,
4845 accessKeyId: ACCESS_KEY_ID ,
49- secretAccessKey: hashedSecretKey ,
46+ secretAccessKey: SECRET_ACCESS_KEY ,
5047 signatureVersion: ' v4' ,
5148 region: ' auto' // Cloudflare R2 doesn't use regions, but this is required by the SDK
5249 });
@@ -233,4 +230,3 @@ export R2_BUCKET_NAME=your_bucket_name
233230 ```
234231 </TabItem >
235232 </Tabs >
236-
You can’t perform that action at this time.
0 commit comments