Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): docs around new AWS SDK JS v3 support. #336

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading