Change upload routine, add upload popup

This commit is contained in:
Romulus Urakagi Tsai 2019-12-24 08:57:34 +00:00
parent 6cdd464f54
commit 93337c20f8
5 changed files with 56 additions and 13 deletions

View file

@ -25,12 +25,7 @@ Utils = {
},
MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL,
COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO,
processUploadedAttachment(card, fileObj, callback) {
const next = attachment => {
if (typeof callback === 'function') {
callback(attachment);
}
};
processUploadedAttachment(card, fileObj, callbacks) {
if (!card) {
return onUploaded();
}
@ -50,7 +45,16 @@ Utils = {
settings.meta.cardId = card._id;
}
settings.meta.userId = Meteor.userId();
Attachments.insert(settings).on('end', next);
if (typeof callbacks === 'function') {
settings.onEnd = callbacks;
} else {
for (const key in callbacks) {
if (key.substring(0, 2) === 'on') {
settings[key] = callbacks[key];
}
}
}
Attachments.insert(settings);
},
shrinkImage(options) {
// shrink image to certain size