summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorSam X. Chen <sam.xi.chen@gmail.com>2019-10-11 11:01:10 -0400
committerSam X. Chen <sam.xi.chen@gmail.com>2019-10-11 11:01:10 -0400
commitf53c624b0f6c6ebcc20c378a153e5cda8d73463c (patch)
treeb65e78165352ddddd4a0b415f3cdf84f5e128072 /models
parent77f8b76d4e13c35ea3451622176bbb69a4d39a32 (diff)
downloadwekan-f53c624b0f6c6ebcc20c378a153e5cda8d73463c.tar.gz
wekan-f53c624b0f6c6ebcc20c378a153e5cda8d73463c.tar.bz2
wekan-f53c624b0f6c6ebcc20c378a153e5cda8d73463c.zip
Buf Fix #2093: the broken should be prior to file attachment feature introduced
Diffstat (limited to 'models')
-rw-r--r--models/export.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/models/export.js b/models/export.js
index a69be970..3f4c8590 100644
--- a/models/export.js
+++ b/models/export.js
@@ -50,12 +50,18 @@ if (Meteor.isServer) {
});
}
+// exporter maybe is broken since Gridfs introduced, add fs and path
+
export class Exporter {
constructor(boardId) {
this._boardId = boardId;
}
build() {
+ const fs = Npm.require('fs');
+ const os = Npm.require('os');
+ const path = Npm.require('path');
+
const byBoard = { boardId: this._boardId };
const byBoardNoLinked = {
boardId: this._boardId,
@@ -134,6 +140,9 @@ export class Exporter {
const getBase64Data = function(doc, callback) {
let buffer = new Buffer(0);
// callback has the form function (err, res) {}
+ const tmpWriteable = fs.createWriteStream(
+ path.join(os.tmpdir(), `tmpexport${process.pid}`),
+ );
const readStream = doc.createReadStream();
readStream.on('data', function(chunk) {
buffer = Buffer.concat([buffer, chunk]);
@@ -145,6 +154,7 @@ export class Exporter {
// done
callback(null, buffer.toString('base64'));
});
+ readStream.pipe(tmpWriteable);
};
const getBase64DataSync = Meteor.wrapAsync(getBase64Data);
result.attachments = Attachments.find(byBoard)