From 8607788975fb708c08e9b6a2da472d37f78a3fef Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Tue, 8 Jun 2021 13:52:36 +0200 Subject: [PATCH] s3fs: use "application/x-directory" as folder mime type This change improve s3fs-fuse compatibility Fixes #451 --- vfs/s3fs.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vfs/s3fs.go b/vfs/s3fs.go index 308575fc..7d0541aa 100644 --- a/vfs/s3fs.go +++ b/vfs/s3fs.go @@ -28,6 +28,9 @@ import ( "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 type S3Fs struct { connectionID string @@ -208,7 +211,7 @@ func (fs *S3Fs) Create(name string, flag int) (File, *PipeWriter, func(), error) key := name var contentType string if flag == -1 { - contentType = dirMimeType + contentType = s3DirMimeType } else { contentType = mime.TypeByExtension(path.Ext(name)) } @@ -267,7 +270,7 @@ func (fs *S3Fs) Rename(source, target string) error { } var contentType string if fi.IsDir() { - contentType = dirMimeType + contentType = s3DirMimeType } else { contentType = mime.TypeByExtension(path.Ext(source)) }