Skip to content

Commit

Permalink
concurrency security fix for content type closed gofiber#1142
Browse files Browse the repository at this point in the history
  • Loading branch information
mstgnz committed Dec 14, 2023
1 parent 0274593 commit 650c2f1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"log"
"net/http"
"sync"
"time"

"github.com/minio/minio-go/v7"
Expand All @@ -18,6 +19,7 @@ type Storage struct {
minio *minio.Client
cfg Config
ctx context.Context
mu sync.Mutex
}

// New creates a new storage
Expand Down Expand Up @@ -92,7 +94,9 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
file := bytes.NewReader(val)

// set content type
s.mu.Lock()
s.cfg.PutObjectOptions.ContentType = http.DetectContentType(val)
s.mu.Unlock()

// put object
_, err := s.minio.PutObject(s.ctx, s.cfg.Bucket, key, file, file.Size(), s.cfg.PutObjectOptions)
Expand Down

0 comments on commit 650c2f1

Please sign in to comment.