diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html
index 6c8fc463f..764a587e0 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.html
+++ b/src-ui/src/app/components/document-detail/document-detail.component.html
@@ -113,6 +113,10 @@
Media filename |
{{metadata?.media_filename}} |
+
+ Original filename |
+ {{metadata?.original_filename}} |
+
Original MD5 checksum |
{{metadata?.original_checksum}} |
diff --git a/src-ui/src/app/data/paperless-document-metadata.ts b/src-ui/src/app/data/paperless-document-metadata.ts
index 1f9155b3a..152f69046 100644
--- a/src-ui/src/app/data/paperless-document-metadata.ts
+++ b/src-ui/src/app/data/paperless-document-metadata.ts
@@ -7,5 +7,7 @@ export interface PaperlessDocumentMetadata {
media_filename?: string
+ original_filename?: string
+
has_archive_version?: boolean
}
diff --git a/src/documents/admin.py b/src/documents/admin.py
index 3e3f1eb1c..6fa06c49b 100644
--- a/src/documents/admin.py
+++ b/src/documents/admin.py
@@ -42,6 +42,7 @@ class DocumentAdmin(admin.ModelAdmin):
"checksum",
"archive_filename",
"archive_checksum",
+ "original_filename",
)
list_display_links = ("title",)
diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index 69a9efb48..d1b01290a 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -203,6 +203,7 @@ class Consumer(LoggingMixin):
script_env["DOCUMENT_TAGS"] = str(
",".join(document.tags.all().values_list("name", flat=True)),
)
+ script_env["DOCUMENT_ORIGINAL_FILENAME"] = str(document.original_filename)
try:
Popen(
@@ -475,6 +476,7 @@ class Consumer(LoggingMixin):
created=create_date,
modified=create_date,
storage_type=storage_type,
+ original_filename=self.filename,
)
self.apply_overrides(document)
diff --git a/src/documents/migrations/1023_document_original_filename.py b/src/documents/migrations/1023_document_original_filename.py
new file mode 100644
index 000000000..065956bd9
--- /dev/null
+++ b/src/documents/migrations/1023_document_original_filename.py
@@ -0,0 +1,25 @@
+# Generated by Django 4.0.6 on 2022-07-25 06:34
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("documents", "1022_paperlesstask"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="document",
+ name="original_filename",
+ field=models.CharField(
+ default=None,
+ editable=False,
+ help_text="The original name of the file when it was uploaded",
+ max_length=1024,
+ null=True,
+ verbose_name="original filename",
+ ),
+ ),
+ ]
diff --git a/src/documents/models.py b/src/documents/models.py
index d8e02e570..f6df273ad 100644
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@ -214,6 +214,16 @@ class Document(models.Model):
help_text=_("Current archive filename in storage"),
)
+ original_filename = models.CharField(
+ _("original filename"),
+ max_length=1024,
+ editable=False,
+ default=None,
+ unique=False,
+ null=True,
+ help_text=_("The original name of the file when it was uploaded"),
+ )
+
archive_serial_number = models.IntegerField(
_("archive serial number"),
blank=True,
diff --git a/src/documents/views.py b/src/documents/views.py
index 84fc38a38..b261f37fd 100644
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -313,6 +313,7 @@ class DocumentViewSet(
"original_metadata": self.get_metadata(doc.source_path, doc.mime_type),
"archive_checksum": doc.archive_checksum,
"archive_media_filename": doc.archive_filename,
+ "original_filename": doc.original_filename,
}
if doc.has_archive_version: