matchatype / s3-example

Simple example using micro for uploading stuff to AWS S3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serverless S3 example

Simple example using Now 2.0, Zeit's micro and the AWS SDK to upload files to the cloud.

JavaScript Style Guide

Deploy to now

How to use

Getting Started

Clone this repo:

Edit config.js:

// ...
  BUCKET_NAME: isNOW ? process.env.BUCKET_NAME : 'micro-s3-example',
  ACCESS_KEY: isNOW ? process.env.ACCESS_KEY : 'ACCESSKEY',
  SECRET_KEY: isNOW ? process.env.SECRET_KEY : 'SECRETKEY',
  REGION: isNOW ? process.env.REGION : 'us-west-1'
// ...

If you are running this example locally, you should edit the fields on the right. If you are planning to test it on now.sh you need to add secrets. Please refer to the section "deploying to now.sh".

Deploying to now.sh

First install now:

npm install -g now

Second you need to add a few now secrets:

now secrets add bucket_name "micro-s3-example"
now secrets add access_key "ACCESSKEY"
now secrets add secret_key "SECRETKEY"
now secrets add region "us-west-1"

PS: The key of those secrets will always be lower case (E.g: BUCKET_NAME will be process.env.bucket_name)

Deploy it to the cloud with now:

now

Check the script "deploy" inside "package.json".

Rest Clients

You can also see this example in action with Insomnia importing the requests from insomnia.json.

Packages Used In This Example

Author

@paulogdm

License

MIT

About

Simple example using micro for uploading stuff to AWS S3.


Languages

Language:JavaScript 100.0%