From 05c53ca01d71a01a608c9ae345475abd67c9939b Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Mon, 18 Nov 2019 01:47:26 +0000 Subject: Trying to upload an attachment with Meteor-Files --- client/components/cards/attachments.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'client/components/cards/attachments.js') diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index e4439155..604dc078 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -149,20 +149,28 @@ Template.previewClipboardImagePopup.events({ if (results && results.file) { window.oPasted = pastedResults; const card = this; - const file = new FS.File(results.file); + const settings = { + file: results.file, + streams: 'dynamic', + chunkSize: 'dynamic' + }; if (!results.name) { // if no filename, it's from clipboard. then we give it a name, with ext name from MIME type + // FIXME: Check this behavior if (typeof results.file.type === 'string') { - file.name(results.file.type.replace('image/', 'clipboard.')); + settings.fileName = new Date().getTime() + results.file.type.replace('.+/', ''); } } - file.updatedAt(new Date()); - file.boardId = card.boardId; - file.cardId = card._id; - file.userId = Meteor.userId(); - const attachment = Attachments.insert(file); + settings.meta = {}; + settings.meta.updatedAt = new Date().getTime(); + settings.meta.boardId = card.boardId; + settings.meta.cardId = card._id; + settings.meta.userId = Meteor.userId(); + console.log('settings', settings); + const attachment = Attachments.insert(settings, false); - if (attachment && attachment._id && attachment.isImage()) { + // TODO: Check image cover behavior + if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } -- cgit v1.2.3-1-g7c22