From 800af0f08a519f6237b8849df11ef4b32fb68663 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Fri, 27 Sep 2024 09:10:38 +0200 Subject: [PATCH] Expose file size in versions metadata Note: file size will only be available for newly uploaded files Close: #7 --- lib/document.rb | 1 + spec/fixtures/document.json | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/document.rb b/lib/document.rb index ea4aa0f..529a53b 100644 --- a/lib/document.rb +++ b/lib/document.rb @@ -214,6 +214,7 @@ def to_hash content_type: content_type, filename: pfile.basename.to_s, path: file_path(v, pfile.basename), + size: pfile.size, author: author, created_at: pfile.mtime, } diff --git a/spec/fixtures/document.json b/spec/fixtures/document.json index a46ba1e..9893972 100644 --- a/spec/fixtures/document.json +++ b/spec/fixtures/document.json @@ -9,12 +9,14 @@ "content_type": "application/zip; charset=binary", "filename": "arglebargle.docx", "path": "/document/app/12345/v001/arglebargle.docx", + "size": 12782, "author": "spliffy" }, "txt": { "content_type": "text/plain; charset=us-ascii", "filename": "arglebargle.txt", "path": "/document/app/12345/v001/arglebargle.txt", + "size": 19, "author": "spliffy" } }, @@ -23,12 +25,14 @@ "content_type": "application/zip; charset=binary", "filename": "arglebargle.docx", "path": "/document/app/12345/v002/arglebargle.docx", + "size": 12782, "author": "spliffy" }, "txt": { "content_type": "text/plain; charset=us-ascii", "filename": "arglebargle.txt", "path": "/document/app/12345/v002/arglebargle.txt", + "size": 19, "author": "spliffy" } }