@resolveio/server-lib 5.2.15 → 5.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/methods/aws.js +7 -5
- package/methods/pdf.js +3 -2
- package/package.json +1 -1
package/methods/aws.js
CHANGED
|
@@ -69,12 +69,13 @@ function loadAWSMethods(methodManager) {
|
|
|
69
69
|
var _this = this;
|
|
70
70
|
var that = this;
|
|
71
71
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
-
var key_1,
|
|
72
|
+
var key_1, file_1, newParams;
|
|
73
|
+
var _this = this;
|
|
73
74
|
return __generator(this, function (_a) {
|
|
74
75
|
if (fileName) {
|
|
75
76
|
key_1 = 'uploads/' + Date.now() + '-' + (pdfCnt++) + '-' + fileName;
|
|
76
77
|
if (fileData.split(',')[0].split(':')[1].split(';')[0] === 'application/pdf' && compress) {
|
|
77
|
-
|
|
78
|
+
file_1 = {
|
|
78
79
|
_id: mongoose_1.Types.ObjectId().toHexString(),
|
|
79
80
|
__v: 0,
|
|
80
81
|
name: fileName,
|
|
@@ -83,10 +84,11 @@ function loadAWSMethods(methodManager) {
|
|
|
83
84
|
order: fileOrder,
|
|
84
85
|
type: fileType
|
|
85
86
|
};
|
|
86
|
-
file_collection_1.Files.create(
|
|
87
|
-
|
|
87
|
+
file_collection_1.Files.create(file_1).then(function (resFile) {
|
|
88
|
+
_this.callMethodInternal.call(_this, 'compressBase64AndUploadPDF', file_1._id, fileName, key_1, fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), function (errCompress, resCompress) {
|
|
89
|
+
resolve(resFile);
|
|
90
|
+
});
|
|
88
91
|
}, function (errFile) { return reject(errFile); });
|
|
89
|
-
this.callMethodInternal.call(this, 'compressBase64AndUploadPDF', file._id, fileName, key_1, fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''));
|
|
90
92
|
}
|
|
91
93
|
else {
|
|
92
94
|
newParams = { Bucket: that.serverConfig.AWSBUCKET, Key: key_1, Body: Buffer.from(fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''), 'base64'), ACL: 'private', ContentType: fileData.split(',')[0].split(':')[1].split(';')[0], ContentDisposition: 'inline' };
|
package/methods/pdf.js
CHANGED
|
@@ -326,8 +326,9 @@ function loadPDFMethods(methodManager) {
|
|
|
326
326
|
_this.callMethodInternal.call(_this, 'insertDocument', 'files', resFile_1, function (errUpFile, resUpFile) {
|
|
327
327
|
if (resUpFile) {
|
|
328
328
|
resFile_1.status = 'Uploaded';
|
|
329
|
-
_this.callMethodInternal.call(_this, 'compressPDFOnS3', resFile_1._id, fileName, mergeFileName)
|
|
330
|
-
|
|
329
|
+
_this.callMethodInternal.call(_this, 'compressPDFOnS3', resFile_1._id, fileName, mergeFileName, function (errCompress, resCompress) {
|
|
330
|
+
resolve(resFile_1);
|
|
331
|
+
});
|
|
331
332
|
}
|
|
332
333
|
else {
|
|
333
334
|
reject(errUpFile);
|