Factor Mime Type guessing into fs.MimeType()
This commit is contained in:
parent
fe68737268
commit
46d39ebaf7
4 changed files with 15 additions and 27 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue