Cloudflare 中文文档
R2
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Configure aws-sdk-js for R2

You must generate an Access Key before getting started. All examples will utilize access_key_id and access_key_secret variables which represent the Access Key ID and Secret Access Key values you generated.

If you are interested in the newer version of the AWS JavaScript SDK visit this dedicated aws-sdk-js-v3 example page.

JavaScript or TypeScript users may continue to use the aws-sdk npm package as per normal. You must pass in the R2 configuration credentials when instantiating your S3 service client:

​​ Generate presigned URLs

You can also generate presigned links that can be used to share public read or write access to a bucket temporarily.

You can use the link generated by the putObject example to upload to the specified bucket and key, until the presigned link expires.