Skip to content

Commit

Permalink
Commit v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
f2face committed May 29, 2024
1 parent e688036 commit df943aa
Show file tree
Hide file tree
Showing 7 changed files with 488 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules
.env
/coverage
/lib
/tests
/tests-js
!.gitkeep
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,30 @@ This is a wrapper of the AWS S3 client library, designed to provide a user-frien
### Installation

#### npm

```bash
npm install node-cloudflare-r2
```

#### pnpm

```bash
pnpm install node-cloudflare-r2
```

> 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: \
> `npm install [email protected]` \
> `npm install [email protected]` \
> or \
> `pnpm install [email protected]` \
> \
> Check the latest version number in the [release page](https://github.com/f2face/cloudflare-r2/releases).
### Example

```javascript
import { R2 } from 'node-cloudflare-r2';
import { createReadStream } from 'fs';

const r2 = new R2({
accountId: '<YOUR_ACCOUNT_ID>',
Expand All @@ -39,6 +50,7 @@ bucket.provideBucketPublicUrl('https://pub-xxxxxxxxxxxxxxxxxxxxxxxxx.r2.dev');
console.log(await bucket.exists());
// true

// Upload local file
const upload = await bucket.uploadFile('/path/to/file', 'destination_file_name.ext');
console.log(upload);
/*
Expand All @@ -50,5 +62,8 @@ console.log(upload);
versionId: '',
}
*/

// Upload file or stream
const uploadStream = await bucket.uploadStream(createReadStream('/path/to/file'), 'destination_file_name-stream.ext');
```

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-cloudflare-r2",
"version": "0.1.5",
"version": "0.2.0",
"description": "S3 wrapper for Cloudflare R2.",
"main": "./lib/index.js",
"scripts": {
Expand Down Expand Up @@ -38,9 +38,9 @@
"url": "https://github.com/f2face/cloudflare-r2.git"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.529.0",
"@aws-sdk/s3-request-presigner": "^3.529.0",
"fast-xml-parser": "4.2.5"
"@aws-sdk/client-s3": "^3.529.1",
"@aws-sdk/lib-storage": "^3.583.0",
"@aws-sdk/s3-request-presigner": "^3.529.1"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.3",
Expand All @@ -58,3 +58,4 @@
"typescript": "^5.4.2"
}
}

Loading

0 comments on commit df943aa

Please sign in to comment.