Simplifying SVG Uploads to Amazon S3 with Flask and Docker
In the ever-expanding world of web development, efficiency and simplicity often go hand in hand. If you find yourself needing to upload SVG files to Amazon S3, this got you covered with a lightweight Flask application that makes the process a breeze.
Getting Started
To get started, clone the repository to your local machine. If you prefer using Docker, build the image and run the container. If not, a local Python environment will do the trick with a simple pip install command.
git clone https://github.com/sudh33ra/svg_uploader_to_s3.git
cd svg-uploader-to-s3
docker build -t svg-uploader .
docker run -p 5001:5001 svg-uploader
Or, for a local Python environment:
pip install boto3 Flask
python app.py
Now, the app is accessible at http://localhost:5001.
How to Use
Once the app is up and running, use tools like Postman or cURL to make a POST request to http://localhost:5001/upload
. Include the necessary form fields:
svg_file_name
: The desired name for your SVG file in S3.
svg_file_content
: The content of your SVG file.
s3_bucket_name
: The name of your S3 bucket.
Receive a JSON response indicating the success or failure of the upload.
Docker Configuration
If you need to set up AWS credentials, mount your AWS credentials and config directory using the following Docker command:
docker run -v /path/to/your/aws:/root/.aws -p 5001:5001 svg-uploader
Ensure your AWS credentials file (/path/to/your/aws/credentials) has the necessary permissions.
Conclusion
With this SVG Uploader to S3, you've got a reliable and straightforward solution for handling SVG file uploads to Amazon S3. Whether you prefer Docker or a local environment, the app is designed to simplify the process, allowing you to focus on what matters most—building incredible web experiences.
Feel free to explore the code, customize it to fit your needs, and happy coding!
Top comments (0)