Skip to content

Commit

Permalink
GCS mime-type detection (drakkan#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-advantitge authored Sep 28, 2020
1 parent 55515fe commit cd56039
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vfs/gcsfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"io"
"mime"
"net/http"
"os"
"path"
Expand Down Expand Up @@ -181,6 +182,10 @@ func (fs GCSFs) Create(name string, flag int) (*os.File, *PipeWriter, func(), er
obj := bkt.Object(name)
ctx, cancelFn := context.WithCancel(context.Background())
objectWriter := obj.NewWriter(ctx)
contentType := mime.TypeByExtension(path.Ext(name))
if contentType != "" {
objectWriter.ObjectAttrs.ContentType = contentType
}
if len(fs.config.StorageClass) > 0 {
objectWriter.ObjectAttrs.StorageClass = fs.config.StorageClass
}
Expand Down

0 comments on commit cd56039

Please sign in to comment.