Factor Mime Type guessing into fs.MimeType()

This commit is contained in:
Nick Craig-Wood 2015-03-01 12:38:31 +00:00
parent fe68737268
commit 46d39ebaf7
4 changed files with 15 additions and 27 deletions

View file

@ -5,6 +5,8 @@ package fs
import (
"fmt"
"io"
"mime"
"path"
"sync"
)
@ -97,6 +99,15 @@ func Equal(src, dst Object) bool {
return true
}
// Returns a guess at the mime type from the extension
func MimeType(o Object) string {
mimeType := mime.TypeByExtension(path.Ext(o.Remote()))
if mimeType == "" {
mimeType = "application/octet-stream"
}
return mimeType
}
// Used to remove a failed copy
func removeFailedCopy(dst Object) {
if dst != nil {