Skip to content

Commit

Permalink
Merge pull request gofiber#1144 from mstgnz/main
Browse files Browse the repository at this point in the history
fix Minio concurrency issues for content type
  • Loading branch information
ReneWerner87 authored Dec 18, 2023
2 parents 114b6f3 + 9ace749 commit 1f2db3a
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,10 +94,12 @@ 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)

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

return err
}
Expand Down

0 comments on commit 1f2db3a

Please sign in to comment.