|
@@ -27,7 +27,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
var (
|
|
var (
|
|
- gcsDefaultFieldsSelection = []string{"Name", "Size", "Deleted", "Updated", "ContentType"}
|
|
|
|
|
|
+ gcsDefaultFieldsSelection = []string{"Name", "Size", "Deleted", "Updated"}
|
|
)
|
|
)
|
|
|
|
|
|
// GCSFs is a Fs implementation for Google Cloud Storage.
|
|
// GCSFs is a Fs implementation for Google Cloud Storage.
|
|
@@ -121,9 +121,6 @@ func (fs GCSFs) Stat(name string) (os.FileInfo, error) {
|
|
if fs.isEqual(attrs.Name, name) {
|
|
if fs.isEqual(attrs.Name, name) {
|
|
isDir := strings.HasSuffix(attrs.Name, "/")
|
|
isDir := strings.HasSuffix(attrs.Name, "/")
|
|
result = NewFileInfo(name, isDir, attrs.Size, attrs.Updated, false)
|
|
result = NewFileInfo(name, isDir, attrs.Size, attrs.Updated, false)
|
|
- if !isDir {
|
|
|
|
- result.setContentType(attrs.ContentType)
|
|
|
|
- }
|
|
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -184,7 +181,7 @@ func (fs GCSFs) Create(name string, flag int) (*os.File, *PipeWriter, func(), er
|
|
objectWriter := obj.NewWriter(ctx)
|
|
objectWriter := obj.NewWriter(ctx)
|
|
contentType := mime.TypeByExtension(path.Ext(name))
|
|
contentType := mime.TypeByExtension(path.Ext(name))
|
|
if contentType != "" {
|
|
if contentType != "" {
|
|
- objectWriter.ObjectAttrs.ContentType = contentType
|
|
|
|
|
|
+ objectWriter.ObjectAttrs.ContentType = contentType
|
|
}
|
|
}
|
|
if len(fs.config.StorageClass) > 0 {
|
|
if len(fs.config.StorageClass) > 0 {
|
|
objectWriter.ObjectAttrs.StorageClass = fs.config.StorageClass
|
|
objectWriter.ObjectAttrs.StorageClass = fs.config.StorageClass
|
|
@@ -359,9 +356,6 @@ func (fs GCSFs) ReadDir(dirname string) ([]os.FileInfo, error) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
fi := NewFileInfo(name, isDir, attrs.Size, attrs.Updated, false)
|
|
fi := NewFileInfo(name, isDir, attrs.Size, attrs.Updated, false)
|
|
- if !isDir {
|
|
|
|
- fi.setContentType(attrs.ContentType)
|
|
|
|
- }
|
|
|
|
result = append(result, fi)
|
|
result = append(result, fi)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -596,3 +590,17 @@ func (fs *GCSFs) getPrefixForStat(name string) string {
|
|
}
|
|
}
|
|
return prefix
|
|
return prefix
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// GetMimeType implements MimeTyper interface
|
|
|
|
+func (fs GCSFs) GetMimeType(name string) (string, error) {
|
|
|
|
+ ctx, cancelFn := context.WithDeadline(context.Background(), time.Now().Add(fs.ctxTimeout))
|
|
|
|
+ defer cancelFn()
|
|
|
|
+ bkt := fs.svc.Bucket(fs.config.Bucket)
|
|
|
|
+ obj := bkt.Object(name)
|
|
|
|
+ attrs, err := obj.Attrs(ctx)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return "", err
|
|
|
|
+ }
|
|
|
|
+ logger.DebugToConsole("content type: %v", attrs.ContentType)
|
|
|
|
+ return attrs.ContentType, nil
|
|
|
|
+}
|