Skip to content

Commit

Permalink
docs(readme): docs around new AWS SDK JS v3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
neverendingqs committed Aug 7, 2024
1 parent d19c3fb commit 3d8a109
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ async function getFile(req, res, next) {
```


### Open.s3([aws-sdk], [params], [options])
### Open.s3([aws-sdk/clients/s3], [params], [options])

This function will return a Promise to the central directory information from a zipfile on S3. Range-headers are used to avoid reading the whole file. Unzipper does not ship with with the aws-sdk so you have to provide an instantiated client as first arguments. The params object requires `Bucket` and `Key` to fetch the correct file.

Supports AWS JavaScript SDK v2 (`aws-sdk/clients/s3`).
See [Open.s3_v3()](#opens3_v3aws-sdk-params-options) for v3 support (`@aws-sdk/client-s3`).

Example:

```js
Expand All @@ -136,6 +139,30 @@ async function main() {
main();
```

### Open.s3_v3([@aws-sdk/client-s3], [params], [options])

Same as [Open.s3()](#opens3aws-sdk-params-options), but for AWS JavaScript SDK v3 (`@aws-sdk/client-s3`).

Example:

```js
const unzipper = require('./unzip');
const { S3Client } = require('@aws-sdk/client-s3');
const s3Client = new S3Client(config);

async function main() {
const directory = await unzipper.Open.s3_v3(s3Client,{Bucket: 'unzipper', Key: 'archive.zip'});
return new Promise( (resolve, reject) => {
directory.files[0]
.stream()
.pipe(fs.createWriteStream('firstFile'))
.on('error',reject)
.on('finish',resolve)
});
}

main();
```

### Open.buffer(buffer, [options])

Expand Down

0 comments on commit 3d8a109

Please sign in to comment.