mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-08-12 04:03:12 +00:00
Add view for video and image (#723)
Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
parent
e8c0e81b57
commit
2ab66f0f93
@ -86,6 +86,7 @@ func parseContentType(fileName string) string {
|
|||||||
parts := strings.Split(fileName, ".")
|
parts := strings.Split(fileName, ".")
|
||||||
if len(parts) >= 2 {
|
if len(parts) >= 2 {
|
||||||
suffix := parts[len(parts)-1]
|
suffix := parts[len(parts)-1]
|
||||||
|
suffix = strings.ToLower(suffix)
|
||||||
switch suffix {
|
switch suffix {
|
||||||
case "txt":
|
case "txt":
|
||||||
contentType = "text/plain"
|
contentType = "text/plain"
|
||||||
@ -109,6 +110,12 @@ func parseContentType(fileName string) string {
|
|||||||
contentType = "video/mpeg"
|
contentType = "video/mpeg"
|
||||||
case "mp4":
|
case "mp4":
|
||||||
contentType = "video/mp4"
|
contentType = "video/mp4"
|
||||||
|
case "ogv":
|
||||||
|
contentType = "video/ogg"
|
||||||
|
case "mov":
|
||||||
|
contentType = "video/mp4"
|
||||||
|
case "webm":
|
||||||
|
contentType = "video/webm"
|
||||||
case "jpeg", "JPEG", "jpg", "JPG":
|
case "jpeg", "JPEG", "jpg", "JPG":
|
||||||
contentType = "image/jpeg"
|
contentType = "image/jpeg"
|
||||||
case "png", "PNG":
|
case "png", "PNG":
|
||||||
@ -117,6 +124,20 @@ func parseContentType(fileName string) string {
|
|||||||
contentType = "image/gif"
|
contentType = "image/gif"
|
||||||
case "svg", "SVG":
|
case "svg", "SVG":
|
||||||
contentType = "image/svg+xml"
|
contentType = "image/svg+xml"
|
||||||
|
case "heic":
|
||||||
|
contentType = "image/heic"
|
||||||
|
case "ico":
|
||||||
|
contentType = "image/x-icon"
|
||||||
|
case "bmp":
|
||||||
|
contentType = "image/bmp"
|
||||||
|
case "tif", "tiff":
|
||||||
|
contentType = "image/tiff"
|
||||||
|
case "psd":
|
||||||
|
contentType = "image/vnd.adobe.photoshop"
|
||||||
|
case "webp":
|
||||||
|
contentType = "image/webp"
|
||||||
|
case "jfif":
|
||||||
|
contentType = "image/jpeg"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,9 @@ static struct file_type_map ftmap[] = {
|
|||||||
{ "mp3", "audio/mp3" },
|
{ "mp3", "audio/mp3" },
|
||||||
{ "mpeg", "video/mpeg" },
|
{ "mpeg", "video/mpeg" },
|
||||||
{ "mp4", "video/mp4" },
|
{ "mp4", "video/mp4" },
|
||||||
|
{ "ogv", "video/ogg" },
|
||||||
|
{ "mov", "video/mp4" },
|
||||||
|
{ "webm", "video/webm" },
|
||||||
{ "jpg", "image/jpeg" },
|
{ "jpg", "image/jpeg" },
|
||||||
{ "JPG", "image/jpeg" },
|
{ "JPG", "image/jpeg" },
|
||||||
{ "jpeg", "image/jpeg" },
|
{ "jpeg", "image/jpeg" },
|
||||||
@ -142,6 +145,14 @@ static struct file_type_map ftmap[] = {
|
|||||||
{ "GIF", "image/gif" },
|
{ "GIF", "image/gif" },
|
||||||
{ "svg", "image/svg+xml" },
|
{ "svg", "image/svg+xml" },
|
||||||
{ "SVG", "image/svg+xml" },
|
{ "SVG", "image/svg+xml" },
|
||||||
|
{ "heic", "image/heic" },
|
||||||
|
{ "ico", "image/x-icon" },
|
||||||
|
{ "bmp", "image/bmp" },
|
||||||
|
{ "tif", "image/tiff" },
|
||||||
|
{ "tiff", "image/tiff" },
|
||||||
|
{ "psd", "image/vnd.adobe.photoshop" },
|
||||||
|
{ "webp", "image/webp" },
|
||||||
|
{ "jfif", "image/jpeg" },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -509,11 +520,16 @@ parse_content_type(const char *filename)
|
|||||||
return NULL;
|
return NULL;
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
|
char *lower = g_utf8_strdown (p, strlen(p));
|
||||||
|
|
||||||
for (i = 0; ftmap[i].suffix != NULL; i++) {
|
for (i = 0; ftmap[i].suffix != NULL; i++) {
|
||||||
if (strcmp(p, ftmap[i].suffix) == 0)
|
if (strcmp(lower, ftmap[i].suffix) == 0) {
|
||||||
|
g_free (lower);
|
||||||
return ftmap[i].type;
|
return ftmap[i].type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (lower);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user