Skip to content

Commit

Permalink
refactor: use entry.Size if valid value
Browse files Browse the repository at this point in the history
Minio works best when it knows the object size prior to upload so if we
have that information we should use it.

The fallback is what we had previously `-1`.

See: https://github.com/minio/minio-go/blob/66ba593a19a7a9d1c302ff2b5c05bf17d73a0d1f/api-put-object.go#L279-L280
  • Loading branch information
neurosnap committed Jul 8, 2024
1 parent f703e13 commit 9d0e2ca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion storage/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ func (s *StorageMinio) PutObject(bucket Bucket, fpath string, contents io.Reader
opts.UserMetadata["Mtime"] = fmt.Sprint(entry.Mtime)
}

info, err := s.Client.PutObject(context.TODO(), bucket.Name, fpath, contents, -1, opts)
var objSize int64 = -1
if entry.Size > 0 {
objSize = entry.Size
}
info, err := s.Client.PutObject(context.TODO(), bucket.Name, fpath, contents, objSize, opts)

if err != nil {
return "", 0, err
Expand Down

0 comments on commit 9d0e2ca

Please sign in to comment.