Start on Heroku: Node.js

by ratewar

GitHub Readme.md

A S3 Image Uploader

A barebones Node.js app using Express 4.

Prerequisites

Make sure you have Node.js and the Heroku CLI installed. Make sure you have account on Heroku An AWS S3 bucket has been created; You have AWS authentication keys that have write access to the bucket. You have enabled CORS (Cross-Origin Resource Sharing) on the bucket so that this application can store files in S3 and browser does not have issues

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
   <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

Running Locally

$ git clone git@github.com:ratewar/uploadimages.git # or clone your own fork
$ cd uploadimages
$ npm install
$ npm start

Your app should now be running on localhost:5000.

Deploying to Heroku

$ heroku login
$ heroku create
$ git push heroku master
$ heroku ps:scale web=1
$ heroku config:set AWS_ACCESS_KEY_ID=xxx AWS_SECRET_ACCESS_KEY=yyy
$ heroku config:set S3_BUCKET=zzz
$ heroku open

or

Deploy to Heroku and go to setting tab and make sure you add environmet variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and S3_BUCKET