https://github.com/numtel/s3-range-zip
Load individual files from zip files on S3 using range
https://github.com/numtel/s3-range-zip
aws s3 zipfile
Last synced: about 1 month ago
JSON representation
Load individual files from zip files on S3 using range
- Host: GitHub
- URL: https://github.com/numtel/s3-range-zip
- Owner: numtel
- Created: 2024-06-06T01:26:28.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-12T11:31:18.000Z (11 months ago)
- Last Synced: 2025-03-04T07:51:20.804Z (3 months ago)
- Topics: aws, s3, zipfile
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/s3-range-zip
- Size: 858 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# s3-range-zip
Load individual files from zip files on S3 without downloading the entire zip using range parameters.
## Installation
```
npm install s3-range-zip
```## Usage
```js
const reader = new S3RangeZip();const fileList = await reader.fetchFileList('bucket', 'key');
console.log(fileList);const file = await reader.downloadFile('bucket', 'key', 'myfile.txt', {encoding: 'utf8'})
console.log(file);
```## class S3RangeZip
### constructor(s3Client)
* `s3UrlFun` `` Optionally, pass a function to use a custom URL scheme.Default:
```js
(bucketName, key) => `https://${bucketName}.s3.amazonaws.com/${key}`
```### async fetchFileList(bucketName, key)
* `bucketName` `` S3 Bucket name
* `key` `` S3 Item keyReturns the list of files in the zip.
### async downloadFile(bucketName, key, fileName, options)
* `bucketName` `` S3 Bucket name
* `key` `` S3 Item key
* `fileName` `` Name of file inside the zip to download and decompress
* `options` `` OptionalOption Name | Type | Description
-----------|-------|----------------
`encoding` | string | `utf8` to return string instead of default `Uint8Array`
`onProgress(receivedBytes, totalBytes)` | function | receive updates during downloadReturns the decompressed file contents as Uint8Array or string.
## License
MIT