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

add metadata feature for files #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following settings must be passed as environment variables as shown in the e
| `aws_bucket` | (Required) The name of the bucket you're upload to. |
| `source_dir` | (Required) The local directory (or file) you wish to upload to S3. The directory will replace to key generated by [shortid](https://github.com/dylang/shortid) in S3 |
| `destination_dir` | (Optional) The destination directory in S3<br />If this field is excluded a [shortid](https://github.com/dylang/shortid) will be generated |
| `file_metadata` | (Optional) File's metadata |

> To upload to the root directory, set `destination_dir: ''` in `action.yml`

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
required: false
default: /
description: 'destination directory for upload'
file_metadata:
required: false
default: ''
description: 'file's metadata'
outputs:
object_key:
description: 'object key'
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const SOURCE_DIR = core.getInput('source_dir', {
const DESTINATION_DIR = core.getInput('destination_dir', {
required: false
});
const METADATA = core.getInput('file_metadata', {
required: false
});

const s3 = new S3({
accessKeyId: AWS_KEY_ID,
Expand Down Expand Up @@ -53,7 +56,7 @@ function run() {
ACL: 'public-read',
Body: fileStream,
Key: bucketPath,
ContentType: lookup(p.path) || 'text/plain'
ContentType: METADATA === '' ? lookup(p.path) : METADATA
};
return upload(params);
})
Expand Down