@resolveio/server-lib 5.2.13 → 5.2.14
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/pdf.js +128 -128
- package/package.json +1 -1
package/methods/pdf.js
CHANGED
|
@@ -120,134 +120,6 @@ function loadPDFMethods(methodManager) {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
compressBase64AndUploadPDF: {
|
|
124
|
-
skipQueue: true,
|
|
125
|
-
check: new simpl_schema_1.default({
|
|
126
|
-
id_file: {
|
|
127
|
-
type: String
|
|
128
|
-
},
|
|
129
|
-
fileName: {
|
|
130
|
-
type: String
|
|
131
|
-
},
|
|
132
|
-
filePath: {
|
|
133
|
-
type: String
|
|
134
|
-
},
|
|
135
|
-
fileContent: {
|
|
136
|
-
type: String
|
|
137
|
-
}
|
|
138
|
-
}),
|
|
139
|
-
function: function (id_file, fileName, filePath, fileContent) {
|
|
140
|
-
var _this = this;
|
|
141
|
-
return new Promise(function (resolve, reject) {
|
|
142
|
-
_this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
|
|
143
|
-
//send request
|
|
144
|
-
request({
|
|
145
|
-
method: 'POST',
|
|
146
|
-
url: 'https:' + resCC.url,
|
|
147
|
-
headers: {
|
|
148
|
-
'Content-Type': 'application/json'
|
|
149
|
-
},
|
|
150
|
-
json: {
|
|
151
|
-
mode: 'compress',
|
|
152
|
-
input: 'base64',
|
|
153
|
-
file: fileContent,
|
|
154
|
-
filename: fileName,
|
|
155
|
-
outputformat: 'pdf',
|
|
156
|
-
wait: true,
|
|
157
|
-
output: {
|
|
158
|
-
's3': {
|
|
159
|
-
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
160
|
-
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
161
|
-
'region': _this.serverConfig['AWSREGION'],
|
|
162
|
-
'bucket': _this.serverConfig['AWSBUCKET'],
|
|
163
|
-
'path': filePath
|
|
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
|
-
}
|
|
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
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}, function (error, response, body) {
|
|
234
|
-
if (!error) {
|
|
235
|
-
if (body.output.size) {
|
|
236
|
-
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
|
|
237
|
-
resolve();
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
reject('Compressed file has no size, compress failed');
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
reject(error);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}, function (errCC) { return reject(errCC); });
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
123
|
mergePDF: {
|
|
252
124
|
skipQueue: true,
|
|
253
125
|
check: new simpl_schema_1.default({
|
|
@@ -441,6 +313,134 @@ function loadPDFMethods(methodManager) {
|
|
|
441
313
|
}, function (errCC) { return reject(errCC); });
|
|
442
314
|
});
|
|
443
315
|
}
|
|
316
|
+
},
|
|
317
|
+
compressBase64AndUploadPDF: {
|
|
318
|
+
skipQueue: true,
|
|
319
|
+
check: new simpl_schema_1.default({
|
|
320
|
+
id_file: {
|
|
321
|
+
type: String
|
|
322
|
+
},
|
|
323
|
+
fileName: {
|
|
324
|
+
type: String
|
|
325
|
+
},
|
|
326
|
+
filePath: {
|
|
327
|
+
type: String
|
|
328
|
+
},
|
|
329
|
+
fileContent: {
|
|
330
|
+
type: String
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
function: function (id_file, fileName, filePath, fileContent) {
|
|
334
|
+
var _this = this;
|
|
335
|
+
return new Promise(function (resolve, reject) {
|
|
336
|
+
_this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
|
|
337
|
+
//send request
|
|
338
|
+
request({
|
|
339
|
+
method: 'POST',
|
|
340
|
+
url: 'https:' + resCC.url,
|
|
341
|
+
headers: {
|
|
342
|
+
'Content-Type': 'application/json'
|
|
343
|
+
},
|
|
344
|
+
json: {
|
|
345
|
+
mode: 'compress',
|
|
346
|
+
input: 'base64',
|
|
347
|
+
file: fileContent,
|
|
348
|
+
filename: fileName,
|
|
349
|
+
outputformat: 'pdf',
|
|
350
|
+
wait: true,
|
|
351
|
+
output: {
|
|
352
|
+
's3': {
|
|
353
|
+
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
354
|
+
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
355
|
+
'region': _this.serverConfig['AWSREGION'],
|
|
356
|
+
'bucket': _this.serverConfig['AWSBUCKET'],
|
|
357
|
+
'path': filePath
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}, function (error, response, body) {
|
|
362
|
+
if (!error) {
|
|
363
|
+
if (body.output.size) {
|
|
364
|
+
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
|
|
365
|
+
resolve();
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
reject('Compressed file has no size, compress failed');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
reject(error);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}, function (errCC) { return reject(errCC); });
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
compressPDFOnS3: {
|
|
380
|
+
skipQueue: true,
|
|
381
|
+
check: new simpl_schema_1.default({
|
|
382
|
+
id_file: {
|
|
383
|
+
type: String
|
|
384
|
+
},
|
|
385
|
+
fileName: {
|
|
386
|
+
type: String
|
|
387
|
+
},
|
|
388
|
+
filePath: {
|
|
389
|
+
type: String
|
|
390
|
+
}
|
|
391
|
+
}),
|
|
392
|
+
function: function (id_file, fileName, filePath) {
|
|
393
|
+
var _this = this;
|
|
394
|
+
return new Promise(function (resolve, reject) {
|
|
395
|
+
_this.callMethodInternal.call(_this, 'getCCProcessURL').then(function (resCC) {
|
|
396
|
+
//send request
|
|
397
|
+
request({
|
|
398
|
+
method: 'POST',
|
|
399
|
+
url: 'https:' + resCC.url,
|
|
400
|
+
headers: {
|
|
401
|
+
'Content-Type': 'application/json'
|
|
402
|
+
},
|
|
403
|
+
json: {
|
|
404
|
+
mode: 'compress',
|
|
405
|
+
input: {
|
|
406
|
+
's3': {
|
|
407
|
+
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
408
|
+
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
409
|
+
'region': _this.serverConfig['AWSREGION'],
|
|
410
|
+
'bucket': _this.serverConfig['AWSBUCKET']
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
file: filePath,
|
|
414
|
+
filename: fileName,
|
|
415
|
+
outputformat: 'pdf',
|
|
416
|
+
wait: true,
|
|
417
|
+
output: {
|
|
418
|
+
's3': {
|
|
419
|
+
'accesskeyid': _this.serverConfig['AWSACCESSKEYID'],
|
|
420
|
+
'secretaccesskey': _this.serverConfig['AWSSECRETACCESSKEY'],
|
|
421
|
+
'region': _this.serverConfig['AWSREGION'],
|
|
422
|
+
'bucket': _this.serverConfig['AWSBUCKET'],
|
|
423
|
+
'path': filePath
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}, function (error, response, body) {
|
|
428
|
+
if (!error) {
|
|
429
|
+
if (body.output.size) {
|
|
430
|
+
file_collection_1.Files.updateOne({ _id: id_file }, { $set: { size: body.output.size } }).exec();
|
|
431
|
+
resolve();
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
reject('Compressed file has no size, compress failed');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
reject(error);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
}, function (errCC) { return reject(errCC); });
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
444
|
}
|
|
445
445
|
});
|
|
446
446
|
}
|