edgi-govdata-archiving / s3-upload-server

Upload Datasets to S3 from the browser
GNU Affero General Public License v3.0
3 stars 0 forks source link
archiving aws heroku s3-bucket

S3 Upload Server

Data rescue efforts often require a method for posting large files to S3 buckets for sharing. This server allows users to post files up to 5GB in size to S3 without needing AWS credentials or knowing how to use the command-line.

I'm still investigating doing multipart uploads from the browser, which would allow files larger than 5GB. I'll update this repo as progress is made.

Features

S3 Requirements

In order for this to work you'll need two settings on the S3 side to be properly configured:

The second AllowedOrigin should be the url of the server you're setting up, as described below. If, for example the app you posted was available at http://data-uploader.herokuapp.com, you'd set the second CORSRule AllowedOrigin to be that url, http://data-uploader.herokuapp.com.

Posting Server to Heroku

Posting this server to Heroku is the easiest way to get up & running publically. Make sure you have a free heroku account, and have installed the heroku CLI on your machine before starting.

  1. Clone the repo.
  2. Navigate to repo directory & run heroku create [app-name].
  3. Set enviornment variables with heroku config:set AWS_REGION=[bucket region] AWS_S3_BUCKET_NAME=[bucket name] AWS_ACCESS_KEY_ID=[access key] AWS_SECRET_ACCESS_KEY=[access secret]
  4. Run git push heroku master to push your code & start the server.
  5. Navigate to http://[app-name].herokuapp.com in your browser & test you're uploads.

Configuring the server

The server accepts configuration in two places, a config.json file, and enviornment variables. Secrets such as the AWS_SECRET_ACCESS_KEY should always be set with enviornment variables.. If you're running this code locally it can be convenient to set these values in the config.json for testing purposes, but they should never be checked into the git repository.

Burner Credentials

To use burner credentials, first the EnableBurnerCredentials configuration option must be true in configuration. Additionally, the configured AWS account must be allowed to perform the sts:GetFederationToken action. For more info, check the sample user policies.

This will open up an endpoint that you can issue GET requests to: /burner?object_name=example.zip&dir=example_directory&format=json

TODO: