mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
Do not override mime types from os defaults
https://forum.rclone.org/t/rclone-serve-http-save-as/26672
This commit is contained in:
parent
8e4b87ae03
commit
16949fde09
@ -5,7 +5,6 @@ import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"log"
|
||||
"mime"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -22,40 +21,6 @@ import (
|
||||
"github.com/rclone/rclone/vfs"
|
||||
)
|
||||
|
||||
// Add a minimal number of mime types to augment go's built in types
|
||||
// for environments which don't have access to a mime.types file (e.g.
|
||||
// Termux on android)
|
||||
func init() {
|
||||
for _, t := range []struct {
|
||||
mimeType string
|
||||
extensions string
|
||||
}{
|
||||
{"audio/flac", ".flac"},
|
||||
{"audio/mpeg", ".mpga,.mpega,.mp2,.mp3,.m4a"},
|
||||
{"audio/ogg", ".oga,.ogg,.opus,.spx"},
|
||||
{"audio/x-wav", ".wav"},
|
||||
{"image/tiff", ".tiff,.tif"},
|
||||
{"video/dv", ".dif,.dv"},
|
||||
{"video/fli", ".fli"},
|
||||
{"video/mpeg", ".mpeg,.mpg,.mpe"},
|
||||
{"video/MP2T", ".ts"},
|
||||
{"video/mp4", ".mp4"},
|
||||
{"video/quicktime", ".qt,.mov"},
|
||||
{"video/ogg", ".ogv"},
|
||||
{"video/webm", ".webm"},
|
||||
{"video/x-msvideo", ".avi"},
|
||||
{"video/x-matroska", ".mpv,.mkv"},
|
||||
{"text/srt", ".srt"},
|
||||
} {
|
||||
for _, ext := range strings.Split(t.extensions, ",") {
|
||||
err := mime.AddExtensionType(ext, t.mimeType)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type contentDirectoryService struct {
|
||||
*server
|
||||
upnp.Eventing
|
||||
|
@ -7,6 +7,42 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Add a minimal number of mime types to augment go's built in types
|
||||
// for environments which don't have access to a mime.types file (e.g.
|
||||
// Termux on android)
|
||||
func init() {
|
||||
for _, t := range []struct {
|
||||
mimeType string
|
||||
extensions string
|
||||
}{
|
||||
{"audio/flac", ".flac"},
|
||||
{"audio/mpeg", ".mpga,.mpega,.mp2,.mp3,.m4a"},
|
||||
{"audio/ogg", ".oga,.ogg,.opus,.spx"},
|
||||
{"audio/x-wav", ".wav"},
|
||||
{"image/tiff", ".tiff,.tif"},
|
||||
{"video/dv", ".dif,.dv"},
|
||||
{"video/fli", ".fli"},
|
||||
{"video/mpeg", ".mpeg,.mpg,.mpe"},
|
||||
{"video/MP2T", ".ts"},
|
||||
{"video/mp4", ".mp4"},
|
||||
{"video/quicktime", ".qt,.mov"},
|
||||
{"video/ogg", ".ogv"},
|
||||
{"video/webm", ".webm"},
|
||||
{"video/x-msvideo", ".avi"},
|
||||
{"video/x-matroska", ".mpv,.mkv"},
|
||||
{"text/srt", ".srt"},
|
||||
} {
|
||||
for _, ext := range strings.Split(t.extensions, ",") {
|
||||
if mime.TypeByExtension(ext) == "" {
|
||||
err := mime.AddExtensionType(ext, t.mimeType)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MimeTypeFromName returns a guess at the mime type from the name
|
||||
func MimeTypeFromName(remote string) (mimeType string) {
|
||||
mimeType = mime.TypeByExtension(path.Ext(remote))
|
||||
|
Loading…
Reference in New Issue
Block a user