add WriteSize option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-05-21 15:05:55 +03:00
parent bfcf22170f
commit f49d72f0b0
3 changed files with 18 additions and 190 deletions

7
s3.go
View File

@@ -189,11 +189,14 @@ func (s *s3Store) Write(ctx context.Context, key string, val interface{}, opts .
}
mputopts := minio.PutObjectOptions{}
writeSize := int64(-1)
if options.Context != nil {
if v, ok := options.Context.Value(contentTypeKey{}).(string); ok && v != "" {
mputopts.ContentType = v
}
if v, ok := options.Context.Value(writeSizeKey{}).(int64); ok && v > 0 {
writeSize = v
}
}
// slow path
@@ -214,7 +217,7 @@ func (s *s3Store) Write(ctx context.Context, key string, val interface{}, opts .
}
}
_, err := s.client.PutObject(ctx, bucket, key, r, int64(-1), mputopts)
_, err := s.client.PutObject(ctx, bucket, key, r, writeSize, mputopts)
return err
}