diff --git a/api.js b/api.js index fc701f9b..bd3bc30b 100644 --- a/api.js +++ b/api.js @@ -1079,7 +1079,7 @@ server.get('/message/:message/attachment/:attachment', (req, res, next) => { } res.writeHead(200, { - 'Content-Type': messageData.metadata.contentType + 'Content-Type': messageData.contentType || 'application/octet-stream' }); let attachmentStream = messageHandler.indexer.gridstore.createReadStream(messageData._id); @@ -1093,7 +1093,6 @@ server.get('/message/:message/attachment/:attachment', (req, res, next) => { } else { attachmentStream.pipe(res); } - }); }); diff --git a/imap-core/lib/indexer/indexer.js b/imap-core/lib/indexer/indexer.js index 9e8774dd..261a9049 100644 --- a/imap-core/lib/indexer/indexer.js +++ b/imap-core/lib/indexer/indexer.js @@ -371,16 +371,13 @@ class Indexer { let store = this.gridstore.createWriteStream(attachmentId, { fsync: true, content_type: contentType, + // metadata should include only minimally required information, this would allow + // to share attachments between different messages if the content is exactly the same + // even though metadata (filename, content-disposition etc) might not metadata: { // if we copy the same message to other mailboxes then instead // of copying attachments we add a pointer to the new message here messages: [messageId], - // decoded filename to display in a web client or API - fileName, - // content-type for the attachment - contentType, - // is it really an attachment? maybe it's a very long text part? - disposition, // how to decode contents if a webclient or API asks for the attachment transferEncoding }