]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Use text mime type for csv files for browser preview 1744/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 4 Oct 2022 18:21:57 +0000 (11:21 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 4 Oct 2022 20:01:06 +0000 (13:01 -0700)
Co-Authored-By: Trenton H <797416+stumpylog@users.noreply.github.com>
Co-Authored-By: bin101 <12427722+bin101@users.noreply.github.com>
src/documents/views.py

index e301ab5f633300296dd2311b5cfe3d360c00ee49..5beab01aa0184e6da358686d7988eeb0a6316f53 100644 (file)
@@ -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)