mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 22:30:56 +03:00
s3fs: use "application/x-directory" as folder mime type
This change improve s3fs-fuse compatibility Fixes #451
This commit is contained in:
@@ -28,6 +28,9 @@ import (
|
|||||||
"github.com/drakkan/sftpgo/version"
|
"github.com/drakkan/sftpgo/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// using this mime type for directories improves compatibility with s3fs-fuse
|
||||||
|
const s3DirMimeType = "application/x-directory"
|
||||||
|
|
||||||
// S3Fs is a Fs implementation for AWS S3 compatible object storages
|
// S3Fs is a Fs implementation for AWS S3 compatible object storages
|
||||||
type S3Fs struct {
|
type S3Fs struct {
|
||||||
connectionID string
|
connectionID string
|
||||||
@@ -208,7 +211,7 @@ func (fs *S3Fs) Create(name string, flag int) (File, *PipeWriter, func(), error)
|
|||||||
key := name
|
key := name
|
||||||
var contentType string
|
var contentType string
|
||||||
if flag == -1 {
|
if flag == -1 {
|
||||||
contentType = dirMimeType
|
contentType = s3DirMimeType
|
||||||
} else {
|
} else {
|
||||||
contentType = mime.TypeByExtension(path.Ext(name))
|
contentType = mime.TypeByExtension(path.Ext(name))
|
||||||
}
|
}
|
||||||
@@ -267,7 +270,7 @@ func (fs *S3Fs) Rename(source, target string) error {
|
|||||||
}
|
}
|
||||||
var contentType string
|
var contentType string
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
contentType = dirMimeType
|
contentType = s3DirMimeType
|
||||||
} else {
|
} else {
|
||||||
contentType = mime.TypeByExtension(path.Ext(source))
|
contentType = mime.TypeByExtension(path.Ext(source))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user