Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Use text mime type for csv files for browser preview

Michael Shamoonc42388f7e2b2
diff --git a/src/documents/views.py b/src/documents/views.py
index e301ab5f6..5beab01aa 100644
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -261,6 +261,9 @@ class DocumentViewSet(
file_handle = doc.source_file
filename = doc.get_public_filename()
mime_type = doc.mime_type
+ # Support browser previewing csv files by using text mime type
+ if mime_type in {"application/csv", "text/csv"} and disposition == "inline":
+ mime_type = "text/plain"
if doc.storage_type == Document.STORAGE_TYPE_GPG:
file_handle = GnuPG.decrypted(file_handle)