A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: send mimetype when saving base64 attachment
Abdullah Atta6ba3732327c2
diff --git a/packages/core/collections/attachments.js b/packages/core/collections/attachments.jsindex 9d9156ed1..46bf16a79 100644--- a/packages/core/collections/attachments.js+++ b/packages/core/collections/attachments.js@@ -282,9 +282,15 @@ export default class Attachments extends Collection {return this._collection.updateItem(attachment);}- async save(data, type) {+ async save(data, type, mimeType) {const key = await this._db.attachments.generateKey();- const metadata = await this._db.fs.writeEncrypted(null, data, type, key);+ const metadata = await this._db.fs.writeEncrypted(+ null,+ data,+ type,+ key,+ mimeType+ );return { key, metadata };}diff --git a/packages/core/collections/content.js b/packages/core/collections/content.jsindex 7511fd088..7eac54924 100644--- a/packages/core/collections/content.js+++ b/packages/core/collections/content.js@@ -163,7 +163,7 @@ export default class Content extends Collection {const content = getContentFromData(contentItem.type, contentItem.data);if (!content) return contentItem;const { data, attachments } = await content.extractAttachments(- (data, type) => this._db.attachments.save(data, type)+ (data, type, mimeType) => this._db.attachments.save(data, type, mimeType));const noteAttachments = allAttachments.filter((attachment) =>diff --git a/packages/core/content-types/tiptap.js b/packages/core/content-types/tiptap.jsindex f036f9387..a80a6149b 100644--- a/packages/core/content-types/tiptap.js+++ b/packages/core/content-types/tiptap.js@@ -161,7 +161,7 @@ export class Tiptap {try {const { data, mime } = dataurl.toObject(image.src);if (!data) continue;- const storeResult = await store(data, "base64");+ const storeResult = await store(data, "base64", mime);if (!storeResult) continue;images[image.id] = { ...storeResult, mime };diff --git a/packages/core/database/fs.js b/packages/core/database/fs.jsindex 2d8912c82..84e8d7796 100644--- a/packages/core/database/fs.js+++ b/packages/core/database/fs.js@@ -73,11 +73,12 @@ export default class FileStorage {return this.fs.readEncrypted(filename, encryptionKey, cipherData);}- writeEncrypted(filename, data, type, encryptionKey) {+ writeEncrypted(filename, data, type, encryptionKey, mimeType) {return this.fs.writeEncrypted(filename, {data,type,- key: encryptionKey+ key: encryptionKey,+ mimeType});}