diff --git a/api4/file.go b/api4/file.go index 1a50aff76c..5fe92b49e3 100644 --- a/api4/file.go +++ b/api4/file.go @@ -42,6 +42,7 @@ var MEDIA_CONTENT_TYPES = [...]string{ "image/png", "image/bmp", "image/gif", + "image/tiff", "video/avi", "video/mpeg", "video/mp4", diff --git a/api4/file_test.go b/api4/file_test.go index 00b78b39c5..bba7dd8ee3 100644 --- a/api4/file_test.go +++ b/api4/file_test.go @@ -346,14 +346,14 @@ func TestUploadFiles(t *testing.T) { // Upload a bunch of files, mixed images and non-images { title: "Happy", - names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md"}, + names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test.tiff"}, expectedCreatorId: th.BasicUser.Id, }, // Upload a bunch of files, with clientIds { title: "Happy client_ids", - names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md"}, - clientIds: []string{"1", "2", "3", "4"}, + names: []string{"test.png", "testgif.gif", "testplugin.tar.gz", "test-search.md", "test.tiff"}, + clientIds: []string{"1", "2", "3", "4", "5"}, expectedCreatorId: th.BasicUser.Id, }, // Upload a bunch of images. testgif.gif is an animated GIF, @@ -478,6 +478,18 @@ func TestUploadFiles(t *testing.T) { expectedImageHasPreview: []bool{true}, expectedCreatorId: th.BasicUser.Id, }, + // TIFF preview test + { + title: "Happy image thumbnail/preview 9", + names: []string{"test.tiff"}, + expectedImageThumbnailNames: []string{"test_expected_thumb.tiff"}, + expectedImagePreviewNames: []string{"test_expected_preview.tiff"}, + expectImage: true, + expectedImageWidths: []int{701}, + expectedImageHeights: []int{701}, + expectedImageHasPreview: []bool{true}, + expectedCreatorId: th.BasicUser.Id, + }, { title: "Happy admin", client: th.SystemAdminClient, diff --git a/model/file.go b/model/file.go index c7ffbf0b9b..e3ee032689 100644 --- a/model/file.go +++ b/model/file.go @@ -13,8 +13,8 @@ const ( ) var ( - IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"} - IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"} + IMAGE_EXTENSIONS = [7]string{".jpg", ".jpeg", ".gif", ".bmp", ".png", ".tiff", "tif"} + IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff", ".tif": "image/tif"} ) type FileUploadResponse struct { diff --git a/tests/test.tiff b/tests/test.tiff new file mode 100644 index 0000000000..7e8c5fdaab Binary files /dev/null and b/tests/test.tiff differ diff --git a/tests/test_expected_preview.tiff b/tests/test_expected_preview.tiff new file mode 100644 index 0000000000..6972917a42 Binary files /dev/null and b/tests/test_expected_preview.tiff differ diff --git a/tests/test_expected_thumb.tiff b/tests/test_expected_thumb.tiff new file mode 100644 index 0000000000..36d4ab758b Binary files /dev/null and b/tests/test_expected_thumb.tiff differ