{"id":17504360,"url":"https://github.com/f2face/cloudflare-r2","last_synced_at":"2025-12-30T09:26:25.547Z","repository":{"id":77263195,"uuid":"604063064","full_name":"f2face/cloudflare-r2","owner":"f2face","description":"Node.js library for Cloudflare R2.","archived":false,"fork":false,"pushed_at":"2023-10-24T23:30:42.000Z","size":231,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-15T12:24:54.334Z","etag":null,"topics":["cloudflare","object-storage","r2"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-cloudflare-r2","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/f2face.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-20T08:58:56.000Z","updated_at":"2024-05-29T12:07:10.846Z","dependencies_parsed_at":null,"dependency_job_id":"3922cdea-91ed-4cd1-a7ad-92c2bdce5c72","html_url":"https://github.com/f2face/cloudflare-r2","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"f7b763752994a451376362c1fd51a42663819d45"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2face%2Fcloudflare-r2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2face%2Fcloudflare-r2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2face%2Fcloudflare-r2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f2face%2Fcloudflare-r2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f2face","download_url":"https://codeload.github.com/f2face/cloudflare-r2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241988411,"owners_count":20053668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare","object-storage","r2"],"created_at":"2024-10-20T00:01:23.978Z","updated_at":"2025-12-30T09:26:25.542Z","avatar_url":"https://github.com/f2face.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Cloudflare-R2\n\nThis is a wrapper of the AWS S3 client library, designed to provide a user-friendly and efficient way to interact with Cloudflare R2 API in Node.js\n\n### Why make this library?\n\n-   As of the writing of this README, there is no official Node.js library for Cloudflare R2.\n-   Interacting with object storage APIs, especially Cloudflare R2, should be simple and straightforward.\n\n\u003e ⚠ This library is currently in development and may not be ready for production use. It is subject to change and may contain bugs or other issues. Please use it at your own risk.\n\n## Installation\n\n#### npm\n\n```bash\nnpm install node-cloudflare-r2\n```\n\n#### pnpm\n\n```bash\npnpm install node-cloudflare-r2\n```\n\n\u003e It is highly recommended that you use a specific version number in your installation to anticipate any breaking changes that may occur in future releases. For example: \\\n\u003e `npm install node-cloudflare-r2@0.4.0` \\\n\u003e or \\\n\u003e `pnpm install node-cloudflare-r2@0.4.0` \\\n\u003e \\\n\u003e Check the latest version number in the [release page](https://github.com/f2face/cloudflare-r2/releases).\n\n## Examples\n\n### Basic usage\n\n```javascript\nimport { R2 } from 'node-cloudflare-r2';\n\n// Initialize R2\nconst r2 = new R2({\n    accountId: '\u003cYOUR_ACCOUNT_ID\u003e',\n    accessKeyId: '\u003cYOUR_R2_ACCESS_KEY_ID\u003e',\n    secretAccessKey: '\u003cYOUR_R2_SECRET_ACCESS_KEY\u003e',\n});\n\n// Initialize bucket instance\nconst bucket = r2.bucket('\u003cBUCKET_NAME\u003e');\n\n// [Optional] Provide the public URL(s) of your bucket, if its public access is allowed.\nbucket.provideBucketPublicUrl('https://pub-xxxxxxxxxxxxxxxxxxxxxxxxx.r2.dev');\n\n// Check if the bucket exists\nconsole.log(await bucket.exists()); // true\n```\n\n### Upload local file (simple)\n\n```javascript\nconst upload = await bucket.uploadFile('/path/to/file', 'destination_file_name.ext');\nconsole.log(upload);\n/*\n{\n    objectKey: 'destination_file_name.ext',\n    uri: 'destination_file_name.ext',\n    publicUrl: 'https://pub-xxxxxxxxxxxxxxxxxxxxxxxxx.r2.dev/destination_file_name.ext',\n    publicUrls: ['https://pub-xxxxxxxxxxxxxxxxxxxxxxxxx.r2.dev/destination_file_name.ext'],\n    etag: '',\n    versionId: '',\n    }\n*/\n```\n\n### Generate GET signed URL with expiration time\n[More about signed URLS on R2](https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js/#generate-presigned-urls)\n\n```javascript\n// Generate GET signed link that expires after 3600 seconds.\nconst signedUrl = await bucket.getObjectSignedUrl('destination_file_name.ext', 3600);\nconsole.log(signedUrl);\n/*\nhttps://bucket-name.cloudflare-account-id.r2.cloudflarestorage.com/destination_file_name.ext?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Content-Sha256=UNSIGNED-PAYLOAD\u0026X-Amz-Credential=...\u0026X-Amz-Date=...\u0026X-Amz-Expires=60\u0026X-Amz-Signature=...\u0026X-Amz-SignedHeaders=host\u0026x-id=GetObject\n*/\n```\n\n### Generate PUT signed URL with expiration time\n[More about signed URLS on R2](https://developers.cloudflare.com/r2/examples/aws/aws-sdk-js/#generate-presigned-urls)\n\n```javascript\n// Generate PUT signed link that expires after 3600 seconds.\nconst signedUrl = await bucket.putObjectSignedUrl('destination_file_name.ext', 3600);\nconsole.log(signedUrl);\n/*\nhttps://bucket-name.cloudflare-account-id.r2.cloudflarestorage.com/destination_file_name.ext?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=...\u003e\u0026X-Amz-Expires=3600\u0026X-Amz-Signature=\u003csignature\u003e\u0026X-Amz-SignedHeaders=host\n*/\n```\n\n### Upload string or binary data or stream\n\n```javascript\n// Upload text content\nconst content = 'Lorem ipsum';\nconst uploadContent = await bucket.upload(content, 'lorem-ipsum.txt');\n```\n\n```javascript\nimport { createReadStream } from 'fs';\n\n// Upload from fs.createReadStream()\nconst stream = createReadStream('/path/to/file');\nconst uploadStream = await bucket.upload(stream, 'destination_file_name2.ext');\n```\n\n### Upload stream (advanced)\n\nThis `bucket.uploadStream()` method allows uploading big file or piping stream or stdout directly to your bucket (using multipart upload internally).\n\n```javascript\n// Let's say, you want to record a live stream and pipe it directly to your bucket.\nimport { spawn } from 'child_process';\n\nconst streamlink = spawn('streamlink', ['--stdout', '\u003cLIVE_STREAM_HLS_URL\u003e', 'best']);\nconst uploadLiveStreamVideo = await bucket.uploadStream(streamlink.stdout, 'my_live_stream.ts');\n```\n\n## Credits\n\nThanks to all [contributors](https://github.com/f2face/cloudflare-r2/graphs/contributors) who have helped improve this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff2face%2Fcloudflare-r2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff2face%2Fcloudflare-r2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff2face%2Fcloudflare-r2/lists"}