Skip to content

Commit 12b6bd1

Browse files
committed
feat: Add MinIO integration for file storage operations
- Introduced MinIO configuration in the application with environment variables. - Implemented API endpoints for file upload, download, deletion, listing, and generating presigned URLs. - Created a MinIO client wrapper to handle interactions with the MinIO service. - Added error handling for various storage operations. - Updated router to include storage-related routes. - Enhanced application context to support MinIO client. - Added documentation for MinIO integration.
1 parent 6526371 commit 12b6bd1

11 files changed

Lines changed: 633 additions & 20 deletions

File tree

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ DB_SSLMODE=disable
2222
# JWT Configuration (if needed)
2323
# JWT_SECRET=your-secret-key
2424
# JWT_EXPIRATION=24h
25+
26+
# MinIO Configuration
27+
MINIO_ENDPOINT=localhost:9000
28+
MINIO_ACCESS_KEY_ID=minioadmin
29+
MINIO_SECRET_ACCESS_KEY=minioadmin
30+
MINIO_USE_SSL=false
31+
MINIO_BUCKET_NAME=unitedapi-storage
32+
33+
# Authentication
34+
SECRET_PASSWORD=your-secret-password

cmd/api/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/UDL-TF/UnitedAPI/internal/logger"
1717
"github.com/UDL-TF/UnitedAPI/internal/middleware"
1818
"github.com/UDL-TF/UnitedAPI/internal/router"
19+
"github.com/UDL-TF/UnitedAPI/internal/storage"
1920
"github.com/gin-gonic/gin"
2021
"go.uber.org/zap"
2122
)
@@ -50,6 +51,13 @@ func main() {
5051
}
5152
appContext.SetDB(db)
5253

54+
// Initialize MinIO client
55+
minioClient, err := storage.NewMinIOClient(&cfg.MinIO)
56+
if err != nil {
57+
log.Fatalf("Failed to initialize MinIO client: %v", err)
58+
}
59+
appContext.SetMinIOClient(minioClient)
60+
5361
// Create Gin engine
5462
engine := gin.New()
5563

docs/MINIO_INTEGRATION.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# MinIO Integration Documentation
2+
3+
## Overview
4+
This API now includes MinIO integration for file storage operations including upload, download, delete, and listing files.
5+
6+
## Environment Variables
7+
Set the following environment variables to configure MinIO:
8+
9+
```bash
10+
MINIO_ENDPOINT=your-minio-endpoint.com:9000
11+
MINIO_ACCESS_KEY_ID=your-username
12+
MINIO_SECRET_ACCESS_KEY=your-password
13+
MINIO_USE_SSL=false
14+
MINIO_BUCKET_NAME=your-bucket-name
15+
```
16+
17+
## API Endpoints
18+
19+
### Upload File
20+
- **Method**: `POST`
21+
- **Endpoint**: `/api/v1/storage/upload`
22+
- **Content-Type**: `multipart/form-data`
23+
- **Parameters**:
24+
- `file` (required): The file to upload
25+
- `object_name` (optional): Custom name for the object (defaults to original filename)
26+
27+
**Example using curl:**
28+
```bash
29+
curl -X POST http://localhost:8080/api/v1/storage/upload \
30+
-F "file=@/path/to/your/file.pdf" \
31+
-F "object_name=my-document.pdf"
32+
```
33+
34+
### Download File
35+
- **Method**: `GET`
36+
- **Endpoint**: `/api/v1/storage/download/{objectName}`
37+
38+
**Example using curl:**
39+
```bash
40+
curl -X GET http://localhost:8080/api/v1/storage/download/my-document.pdf \
41+
--output downloaded-file.pdf
42+
```
43+
44+
### Delete File
45+
- **Method**: `DELETE`
46+
- **Endpoint**: `/api/v1/storage/delete/{objectName}`
47+
48+
**Example using curl:**
49+
```bash
50+
curl -X DELETE http://localhost:8080/api/v1/storage/delete/my-document.pdf
51+
```
52+
53+
### List Files
54+
- **Method**: `GET`
55+
- **Endpoint**: `/api/v1/storage/files`
56+
- **Query Parameters**:
57+
- `prefix` (optional): Filter files by prefix
58+
59+
**Example using curl:**
60+
```bash
61+
curl -X GET "http://localhost:8080/api/v1/storage/files?prefix=documents/"
62+
```
63+
64+
### Generate Presigned URL
65+
- **Method**: `GET`
66+
- **Endpoint**: `/api/v1/storage/presigned/{objectName}`
67+
- **Query Parameters**:
68+
- `method` (optional): GET or PUT (default: GET)
69+
- `expiry` (optional): Duration like "1h", "30m", "24h" (default: 1h)
70+
71+
**Example using curl:**
72+
```bash
73+
curl -X GET "http://localhost:8080/api/v1/storage/presigned/my-document.pdf?method=GET&expiry=2h"
74+
```
75+
76+
## Example Response Format
77+
78+
### Success Response
79+
```json
80+
{
81+
"success": true,
82+
"message": "File uploaded successfully",
83+
"data": {
84+
"object_name": "my-document.pdf",
85+
"size": 1024000,
86+
"content_type": "application/pdf"
87+
}
88+
}
89+
```
90+
91+
### Error Response
92+
```json
93+
{
94+
"success": false,
95+
"message": "Failed to upload file",
96+
"error": "detailed error message"
97+
}
98+
```
99+
100+
## Features
101+
102+
1. **Automatic Bucket Creation**: The system automatically creates the configured bucket if it doesn't exist
103+
2. **File Upload**: Upload files via multipart form data
104+
3. **File Download**: Download files with proper headers and streaming
105+
4. **File Deletion**: Remove files from storage
106+
5. **File Listing**: List all files with optional prefix filtering
107+
6. **Presigned URLs**: Generate time-limited direct access URLs
108+
7. **File Metadata**: Get file information including size, content type, and modification date
109+
110+
## Error Handling
111+
The API includes comprehensive error handling for:
112+
- MinIO connection issues
113+
- File not found errors
114+
- Invalid parameters
115+
- Upload/download failures
116+
- Authorization issues
117+
118+
## Security Notes
119+
- Store MinIO credentials securely using environment variables
120+
- Use HTTPS in production (set `MINIO_USE_SSL=true`)
121+
- Implement proper authentication/authorization for file operations
122+
- Consider adding file size limits and type restrictions
123+
- Use presigned URLs for direct client uploads to reduce server load

go.mod

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module github.com/UDL-TF/UnitedAPI
22

3-
go 1.23.3
3+
go 1.24.0
44

55
require (
66
github.com/gin-contrib/cors v1.7.2
77
github.com/gin-gonic/gin v1.9.1
8+
github.com/minio/minio-go/v7 v7.0.98
89
go.uber.org/zap v1.27.1
910
gorm.io/driver/postgres v1.5.9
1011
gorm.io/gorm v1.25.12
@@ -15,34 +16,45 @@ require (
1516
github.com/bytedance/sonic/loader v0.1.1 // indirect
1617
github.com/cloudwego/base64x v0.1.4 // indirect
1718
github.com/cloudwego/iasm v0.2.0 // indirect
19+
github.com/dustin/go-humanize v1.0.1 // indirect
1820
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
1921
github.com/gin-contrib/sse v0.1.0 // indirect
22+
github.com/go-ini/ini v1.67.0 // indirect
2023
github.com/go-playground/locales v0.14.1 // indirect
2124
github.com/go-playground/universal-translator v0.18.1 // indirect
2225
github.com/go-playground/validator/v10 v10.20.0 // indirect
2326
github.com/goccy/go-json v0.10.2 // indirect
27+
github.com/google/uuid v1.6.0 // indirect
2428
github.com/jackc/pgpassfile v1.0.0 // indirect
2529
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
2630
github.com/jackc/pgx/v5 v5.5.5 // indirect
2731
github.com/jackc/puddle/v2 v2.2.1 // indirect
2832
github.com/jinzhu/inflection v1.0.0 // indirect
2933
github.com/jinzhu/now v1.1.5 // indirect
3034
github.com/json-iterator/go v1.1.12 // indirect
31-
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
35+
github.com/klauspost/compress v1.18.2 // indirect
36+
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
37+
github.com/klauspost/crc32 v1.3.0 // indirect
3238
github.com/leodido/go-urn v1.4.0 // indirect
3339
github.com/mattn/go-isatty v0.0.20 // indirect
40+
github.com/minio/crc64nvme v1.1.1 // indirect
41+
github.com/minio/md5-simd v1.1.2 // indirect
3442
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3543
github.com/modern-go/reflect2 v1.0.2 // indirect
3644
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
45+
github.com/philhofer/fwd v1.2.0 // indirect
46+
github.com/rs/xid v1.6.0 // indirect
47+
github.com/tinylib/msgp v1.6.1 // indirect
3748
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
3849
github.com/ugorji/go/codec v1.2.12 // indirect
3950
go.uber.org/multierr v1.10.0 // indirect
51+
go.yaml.in/yaml/v3 v3.0.4 // indirect
4052
golang.org/x/arch v0.7.0 // indirect
41-
golang.org/x/crypto v0.22.0 // indirect
42-
golang.org/x/net v0.24.0 // indirect
43-
golang.org/x/sync v0.1.0 // indirect
44-
golang.org/x/sys v0.19.0 // indirect
45-
golang.org/x/text v0.14.0 // indirect
53+
golang.org/x/crypto v0.46.0 // indirect
54+
golang.org/x/net v0.48.0 // indirect
55+
golang.org/x/sync v0.19.0 // indirect
56+
golang.org/x/sys v0.39.0 // indirect
57+
golang.org/x/text v0.32.0 // indirect
4658
google.golang.org/protobuf v1.34.0 // indirect
4759
gopkg.in/yaml.v3 v3.0.1 // indirect
4860
)

go.sum

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ
99
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1010
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1111
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
13+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
1214
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
1315
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
1416
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
@@ -17,6 +19,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
1719
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
1820
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
1921
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
22+
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
23+
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
2024
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
2125
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
2226
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
@@ -30,6 +34,8 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
3034
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
3135
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
3236
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
37+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
38+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3339
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
3440
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
3541
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
@@ -44,9 +50,14 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
4450
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
4551
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
4652
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
53+
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
54+
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
55+
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
4756
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
48-
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
49-
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
57+
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
58+
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
59+
github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM=
60+
github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw=
5061
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
5162
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
5263
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
@@ -56,17 +67,27 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
5667
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
5768
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
5869
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
70+
github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI=
71+
github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
72+
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
73+
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
74+
github.com/minio/minio-go/v7 v7.0.98 h1:MeAVKjLVz+XJ28zFcuYyImNSAh8Mq725uNW4beRisi0=
75+
github.com/minio/minio-go/v7 v7.0.98/go.mod h1:cY0Y+W7yozf0mdIclrttzo1Iiu7mEf9y7nk2uXqMOvM=
5976
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
6077
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
6178
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
6279
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
6380
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
6481
github.com/pelletier/go-toml/v2 v2.2.1 h1:9TA9+T8+8CUCO2+WYnDLCgrYi9+omqKXyjDtosvtEhg=
6582
github.com/pelletier/go-toml/v2 v2.2.1/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
83+
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
84+
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
6685
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6786
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
6887
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
6988
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
89+
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
90+
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
7091
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7192
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
7293
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -79,6 +100,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
79100
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
80101
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
81102
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
103+
github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY=
104+
github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
82105
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
83106
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
84107
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -89,21 +112,22 @@ go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
89112
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
90113
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
91114
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
115+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
116+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
92117
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
93118
golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc=
94119
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
95-
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
96-
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
97-
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
98-
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
99-
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
100-
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
101-
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
120+
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
121+
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
122+
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
123+
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
124+
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
125+
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
102126
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
103-
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
104-
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
105-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
106-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
127+
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
128+
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
129+
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
130+
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
107131
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
108132
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
109133
google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4=

internal/config/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Config struct {
1111
Server ServerConfig
1212
Database DatabaseConfig
1313
Auth AuthConfig
14+
MinIO MinIOConfig
1415
// Add more config sections as needed
1516
// Redis RedisConfig
1617
// JWT JWTConfig
@@ -38,6 +39,15 @@ type DatabaseConfig struct {
3839
SSLMode string
3940
}
4041

42+
// MinIOConfig holds MinIO configuration
43+
type MinIOConfig struct {
44+
Endpoint string
45+
AccessKeyID string
46+
SecretAccessKey string
47+
UseSSL bool
48+
BucketName string
49+
}
50+
4151
// Load loads configuration from environment variables
4252
func Load() *Config {
4353
return &Config{
@@ -57,6 +67,13 @@ func Load() *Config {
5767
Auth: AuthConfig{
5868
SecretPassword: getEnv("SECRET_PASSWORD", ""),
5969
},
70+
MinIO: MinIOConfig{
71+
Endpoint: getEnv("MINIO_ENDPOINT", ""),
72+
AccessKeyID: getEnv("MINIO_ACCESS_KEY_ID", ""),
73+
SecretAccessKey: getEnv("MINIO_SECRET_ACCESS_KEY", ""),
74+
UseSSL: getEnvBool("MINIO_USE_SSL", false),
75+
BucketName: getEnv("MINIO_BUCKET_NAME", "default"),
76+
},
6077
}
6178
}
6279

0 commit comments

Comments
 (0)