HUB
Sign inSign up
aws-uploads-sample logo

so0k/aws-uploads-sample

By so0k

•Updated over 9 years ago

Sample Flask app to upload files to s3

Image
0

1.2K

so0k/aws-uploads-sample repository overview

⁠AWS Direct Upload Sample

Simple example demonstrating how to accomplish a direct upload to Amazon S3 in a Python Flask application.

Ideally the static assets are processed (minified / compressed) and served from a CDN instead of this app itself.

⁠Running the application

  • Set environment variables for your AWS access key, secret, and bucket name

  • Run:

    docker build -t aws-uploads-sample .
    docker run -d --name "uploader" -p 5000:5000 \
        -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" \
        -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" \
        -e "S3_BUCKET=${S3_BUCKET}" \
        -e "S3_REGION=${S3_REGION}" \
        aws-uploads-sample
    
  • Visit localhost:5000/upload⁠ to try it out

⁠Troubleshooting

You can test the AWS credentials provided have the rights to upload as follows:


$ docker exec -it uploader sh

$ python
import boto3
from botocore.client import Config
s3 = boto3.client('s3', 'ap-southeast-1',config=Config(s3={'addressing_style':'path'}))
s3.upload_file('application.py','myBucket','application.py')

⁠Source

This sample app is a direct copy of:

⁠Licensing

The files in this repository are, unless stated otherwise, released under the Apache License. You are free to redistribute this code with or without modification. The full license text is available here⁠.

Tag summary
Recent tags
Content type
Image
Digest
Size
36 MB
Last updated
over 9 years ago
docker pull so0k/aws-uploads-sample:latest