A golang application that generates Qr Codes and stores them in AWS S3. This project demonstrate the integration of skip2 library for QR code generation and AWS S3 for storage.
This section provides comprehensive instructions for setting up and running the QR Code Generator application.
- Golang 1.24.3
- AWS Account with S3 access
- AWS CLI configured with appropriate credentials
Create a .env file in the project root with the following variables:
AWS_SECRET_KEY=your_secret_key
AWS_ACCESS_KEY=your_acess_ley
AWS_S3_BUCKET=your_bucket_name
AWS_REGION=your_region- Create the
.envfile as described above - Donwload dependencies with:
go mod tidy - Run the application:
go run cmd/main.go- Create a S3 bucket in your AWS account
- Update the
AWS_S3_BUCKETin your.env - Ensure your AWS credentials have appropriate permissions to acess the S3 bucket
POST /qrcode
Generate a QR code from the provided text and store it in AWS S3. The QR code will be generated as a PNG image.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
text |
required | string | The text content to be encoded in the QR code. This can be any string value that you want to convert into a QR code. |
Response
{
"url": "https://your-bucket.s3.your-region.amazonaws.com/random-uuid"
}Error Response
If an error occurs during QR code generation or S3 upload, the API will return a 500 Internal Server Error.
Example Usage
curl -X POST http://localhost:3050/qrcode \
-H "Content-Type: application/json" \
-d '{"text": "https://example.com"}'This project is licensed under the MIT License - see the LICENSE file for details.