From 2b84cd0b115a93e65765f6237fdb367c55d63dc9 Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Tue, 27 Feb 2018 15:02:23 +0100 Subject: [PATCH] update doc to file --- src/shape/docToFile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shape/docToFile.js b/src/shape/docToFile.js index c38553e..40aa9b4 100644 --- a/src/shape/docToFile.js +++ b/src/shape/docToFile.js @@ -34,7 +34,11 @@ export default async function docToFile(db, doc, { image = false, sketch = false } } if (image) { - response.img = `${db.name}/${doc._id}/img`; + if (!(doc._attachments && doc._attachments.img && doc._attachments.img.data)) { + throw new Error(`'${doc.name}' doesn't include image attachment`); + } + + response.img = URL.createObjectURL(doc._attachments.img.data); } return response;