forked from akapuya/s3-unzip-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from 20minutes/rebuild
Rebuild using AWS SDK v3
- Loading branch information
Showing
13 changed files
with
3,756 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_size = 2 | ||
|
||
[*.yml] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "@20minutes", | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Quality checks | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.x | ||
cache: 'yarn' | ||
|
||
- run: yarn install | ||
|
||
- run: yarn lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- run: yarn install | ||
- run: yarn test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: yarn install | ||
- run: yarn publish --access public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ node_modules | |
|
||
.DS_Store | ||
*.zip | ||
package-lock.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,30 @@ | ||
# S3 Unzip plus # | ||
# S3 Unzip Plus # | ||
|
||
A simple library to unzip an archive file in a S3 bucket to its root folder. | ||
Forked version to: | ||
- remove old AWS SDK v2 | ||
- add AWS SDK v3 | ||
- convert to async/await | ||
|
||
### Install ### | ||
For the official readme, check the [official project](https://github.com/akapuya/s3-unzip-plus). | ||
|
||
- To include as library: `npm install s3-unzip-plus` | ||
- To use as a command-line tool: `npm install -g s3-unzip-plus` | ||
### Install | ||
|
||
### Restrictions ### | ||
|
||
- The module only supports the input zip file MIME type of 'application/zip'. | ||
|
||
### Command Line Usage ### | ||
|
||
`s3-unzip-plus [-dv] <bucket name> <filename>` | ||
|
||
#### Required #### | ||
|
||
- `<bucket name>` : Bucket name in S3 where the zip file exists | ||
- `<filename>` : Filename (including the .zip extension) of the archive that will be decompressed | ||
|
||
#### Options #### | ||
|
||
- `<targetBucket>` : the output bucket | ||
- `<targetKey>` : target folder | ||
- `-d, --delete-on-success` : Delete the zip file once the decompression has finished | ||
- `-v, --verbose` : Show the console log messages during runtime | ||
|
||
#### Example #### | ||
|
||
`s3-unzip-plus -d -v test-bucket-in-s3 Companies.zip` | ||
``` | ||
yarn add @20minutes/s3-unzip-plus | ||
``` | ||
|
||
### Library Usage ### | ||
|
||
Include like most libraries: | ||
|
||
`var s3Unziplus = require("s3-unzip-plus");` | ||
|
||
Run the decompression for the file in the specified bucket: | ||
|
||
#### Options #### | ||
|
||
~~~~ | ||
var s = new s3Unziplus({ | ||
bucket: "test-bucket-in-s3", | ||
file: "Companies.zip", | ||
targetBucket: "test-output-bucket", | ||
targetKey: "test-folder", | ||
copyMetadata: true, | ||
deleteOnSuccess: true, | ||
verbose: false | ||
}, function(err, success){ | ||
if (err) console.error(err); | ||
else console.log(success); | ||
}); | ||
~~~~ | ||
|
||
### AWS Lambda Usage ### | ||
|
||
Create an AWS Lambda function, name it, and zip all files from this package to upload the code (including node_modules). The function defaults to deleting the zip file after it's been decompressed and verbose messages logged to CloudWatch. | ||
|
||
#### Configuration #### | ||
|
||
##### Basic ##### | ||
- Runtime: **Node.js 6.10** | ||
- Handler: **index.handler** | ||
- Role: **(create a custom role with Full S3 Access)** | ||
|
||
##### Advanced ##### | ||
|
||
For a 20MB zip file: | ||
- Memory: **at least 512MB** | ||
- Timeout: **at least 30 sec** | ||
|
||
#### Options #### | ||
|
||
Test JSON: | ||
~~~~ | ||
{ | ||
"event":{ | ||
"Records": [ | ||
{ | ||
"s3": { | ||
"bucket": { | ||
"name": "test-bucket-in-s3" | ||
}, | ||
"object": { | ||
"key": "Companies.zip" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
~~~~ | ||
```js | ||
import s3UnzipPlus from '@20minutes/s3-unzip-plus' | ||
|
||
await s3UnzipPlus({ | ||
bucket: 'test-bucket-in-s3', | ||
file: 'Companies.zip', | ||
targetBucket: 'test-output-bucket', | ||
targetKey: 'test-folder', | ||
copyMetadata: true, | ||
deleteOnSuccess: true, | ||
verbose: false | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.