feat(azure): added the content encoding support
This commit is contained in:
parent
16182031e1
commit
b4d2e685de
1 changed files with 7 additions and 4 deletions
|
|
@ -52,14 +52,17 @@ func NewStorage(cfg *config.ObjectsConfig) (objectstorage.ObjectStorage, error)
|
|||
|
||||
func (s *storageImpl) Upload(reader io.Reader, key string, contentType string, compression objectstorage.CompressionType) error {
|
||||
cacheControl := "max-age=2628000, immutable, private"
|
||||
var contentEncoding *string
|
||||
var encoding *string
|
||||
switch compression {
|
||||
case objectstorage.Gzip:
|
||||
gzipStr := "gzip"
|
||||
contentEncoding = &gzipStr
|
||||
encoding = &gzipStr
|
||||
case objectstorage.Brotli:
|
||||
gzipStr := "br"
|
||||
contentEncoding = &gzipStr
|
||||
encoding = &gzipStr
|
||||
}
|
||||
if contentEncoding != "" {
|
||||
encoding = &contentEncoding
|
||||
}
|
||||
// Remove leading slash to avoid empty folder creation
|
||||
if strings.HasPrefix(key, "/") {
|
||||
|
|
@ -68,7 +71,7 @@ func (s *storageImpl) Upload(reader io.Reader, key string, contentType string, c
|
|||
_, err := s.client.UploadStream(context.Background(), s.container, key, reader, &azblob.UploadStreamOptions{
|
||||
HTTPHeaders: &blob.HTTPHeaders{
|
||||
BlobCacheControl: &cacheControl,
|
||||
BlobContentEncoding: contentEncoding,
|
||||
BlobContentEncoding: encoding,
|
||||
BlobContentType: &contentType,
|
||||
},
|
||||
Tags: s.tags,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue