@resolveio/server-lib 5.2.11 → 5.2.12
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 +1 -1
- package/methods/pdf.js +68 -1
- package/package.json +1 -1
package/methods/aws.js
CHANGED
|
@@ -86,7 +86,7 @@ function loadAWSMethods(methodManager) {
|
|
|
86
86
|
file_collection_1.Files.create(file).then(function (resFile) {
|
|
87
87
|
resolve(resFile);
|
|
88
88
|
}, function (errFile) { return reject(errFile); });
|
|
89
|
-
this.callMethodInternal.call(this, '
|
|
89
|
+
this.callMethodInternal.call(this, 'compressBase64AndUploadPDF', file._id, fileName, key_1, fileData.replace('data:' + fileData.split(',')[0].split(':')[1].split(';')[0] + ';base64,', ''));
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
92
|
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
|
@@ -120,7 +120,7 @@ function loadPDFMethods(methodManager) {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
compressBase64AndUploadPDF: {
|
|
124
124
|
skipQueue: true,
|
|
125
125
|
check: new simpl_schema_1.default({
|
|
126
126
|
id_file: {
|
|
@@ -162,7 +162,73 @@ function loadPDFMethods(methodManager) {
|
|
|
162
162
|
'bucket': _this.serverConfig['AWSBUCKET'],
|
|
163
163
|
'path': filePath
|
|
164
164
|
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, function (error, response, body) {
|
|
168
|
+
if (!error) {
|
|
169
|
+
if (body.output.size) {
|
|
170
|
+
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
|
|
171
|
+
resolve();
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
reject('Compressed file has no size, compress failed');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
reject(error);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}, function (errCC) { return reject(errCC); });
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
compressPDFOnS3: {
|
|
186
|
+
skipQueue: true,
|
|
187
|
+
check: new simpl_schema_1.default({
|
|
188
|
+
id_file: {
|
|
189
|
+
type: String
|
|
190
|
+
},
|
|
191
|
+
fileName: {
|
|
192
|
+
type: String
|
|
193
|
+
},
|
|
194
|
+
filePath: {
|
|
195
|
+
type: String
|
|
196
|
+
}
|
|
197
|
+
}),
|
|
198
|
+
function: function (id_file, fileName, filePath) {
|
|
199
|
+
var _this = this;
|
|
200
|
+
return new Promise(function (resolve, reject) {
|
|
201
|
+
_this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
|
|
202
|
+
//send request
|
|
203
|
+
request({
|
|
204
|
+
method: 'POST',
|
|
205
|
+
url: 'https:' + resCC.url,
|
|
206
|
+
headers: {
|
|
207
|
+
'Content-Type': 'application/json'
|
|
208
|
+
},
|
|
209
|
+
json: {
|
|
210
|
+
mode: 'compress',
|
|
211
|
+
input: {
|
|
212
|
+
's3': {
|
|
213
|
+
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
214
|
+
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
215
|
+
'region': _this.serverConfig['AWSREGION'],
|
|
216
|
+
'bucket': _this.serverConfig['AWSBUCKET']
|
|
217
|
+
}
|
|
165
218
|
},
|
|
219
|
+
file: filePath,
|
|
220
|
+
filename: fileName,
|
|
221
|
+
outputformat: 'pdf',
|
|
222
|
+
wait: true,
|
|
223
|
+
output: {
|
|
224
|
+
's3': {
|
|
225
|
+
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
226
|
+
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
227
|
+
'region': _this.serverConfig['AWSREGION'],
|
|
228
|
+
'bucket': _this.serverConfig['AWSBUCKET'],
|
|
229
|
+
'path': filePath
|
|
230
|
+
}
|
|
231
|
+
}
|
|
166
232
|
}
|
|
167
233
|
}, function (error, response, body) {
|
|
168
234
|
if (!error) {
|
|
@@ -260,6 +326,7 @@ function loadPDFMethods(methodManager) {
|
|
|
260
326
|
_this.callMethodInternal.call(_this, 'insertDocument', 'files', resFile_1, function (errUpFile, resUpFile) {
|
|
261
327
|
if (resUpFile) {
|
|
262
328
|
resFile_1.status = 'Uploaded';
|
|
329
|
+
_this.callMethodInternal.call(_this, 'compressPDFOnS3', resFile_1._id, fileName, mergeFileName);
|
|
263
330
|
resolve(resFile_1);
|
|
264
331
|
}
|
|
265
332
|
else {
|