mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Buf Fix #2093: the broken should be prior to file attachment feature introduced
This commit is contained in:
parent
77f8b76d4e
commit
f53c624b0f
1 changed files with 10 additions and 0 deletions
|
|
@ -50,12 +50,18 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// exporter maybe is broken since Gridfs introduced, add fs and path
|
||||||
|
|
||||||
export class Exporter {
|
export class Exporter {
|
||||||
constructor(boardId) {
|
constructor(boardId) {
|
||||||
this._boardId = boardId;
|
this._boardId = boardId;
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
const fs = Npm.require('fs');
|
||||||
|
const os = Npm.require('os');
|
||||||
|
const path = Npm.require('path');
|
||||||
|
|
||||||
const byBoard = { boardId: this._boardId };
|
const byBoard = { boardId: this._boardId };
|
||||||
const byBoardNoLinked = {
|
const byBoardNoLinked = {
|
||||||
boardId: this._boardId,
|
boardId: this._boardId,
|
||||||
|
|
@ -134,6 +140,9 @@ export class Exporter {
|
||||||
const getBase64Data = function(doc, callback) {
|
const getBase64Data = function(doc, callback) {
|
||||||
let buffer = new Buffer(0);
|
let buffer = new Buffer(0);
|
||||||
// callback has the form function (err, res) {}
|
// callback has the form function (err, res) {}
|
||||||
|
const tmpWriteable = fs.createWriteStream(
|
||||||
|
path.join(os.tmpdir(), `tmpexport${process.pid}`),
|
||||||
|
);
|
||||||
const readStream = doc.createReadStream();
|
const readStream = doc.createReadStream();
|
||||||
readStream.on('data', function(chunk) {
|
readStream.on('data', function(chunk) {
|
||||||
buffer = Buffer.concat([buffer, chunk]);
|
buffer = Buffer.concat([buffer, chunk]);
|
||||||
|
|
@ -145,6 +154,7 @@ export class Exporter {
|
||||||
// done
|
// done
|
||||||
callback(null, buffer.toString('base64'));
|
callback(null, buffer.toString('base64'));
|
||||||
});
|
});
|
||||||
|
readStream.pipe(tmpWriteable);
|
||||||
};
|
};
|
||||||
const getBase64DataSync = Meteor.wrapAsync(getBase64Data);
|
const getBase64DataSync = Meteor.wrapAsync(getBase64Data);
|
||||||
result.attachments = Attachments.find(byBoard)
|
result.attachments = Attachments.find(byBoard)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue