@docbrasil/api-systemmanager 1.0.70 → 1.0.71
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/api/user/document.js +17 -4
- package/dist/bundle.cjs +16 -3
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +6 -0
- package/package.json +1 -1
package/api/user/document.js
CHANGED
|
@@ -503,6 +503,7 @@ class Documents {
|
|
|
503
503
|
* @param {buffer} params.content The content of the file (Buffer)
|
|
504
504
|
* @param {string} params.signedUrl The signed URL
|
|
505
505
|
* @param {string} params.type The file mime type
|
|
506
|
+
* @param {string} params.onUploadProgress A callback for the upload progress. It will return a progressEvent.
|
|
506
507
|
* @return {Promise<boolean>} True if success
|
|
507
508
|
*
|
|
508
509
|
* @public
|
|
@@ -519,8 +520,13 @@ class Documents {
|
|
|
519
520
|
* type: 'application/pdf'
|
|
520
521
|
* };
|
|
521
522
|
* const retData = await api.user.document.uploadSignedDocument(params);
|
|
523
|
+
*
|
|
524
|
+
* onUploadProgress return the progressEvent
|
|
525
|
+
* - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
|
|
526
|
+
* - loaded: The number of bytes of the file that have been uploaded.
|
|
527
|
+
* - total: The total number of bytes in the file.
|
|
522
528
|
*/
|
|
523
|
-
async uploadSignedDocument(params) {
|
|
529
|
+
async uploadSignedDocument(params= {}) {
|
|
524
530
|
const { content, signedUrl, type } = params;
|
|
525
531
|
Joi.assert(params, Joi.object().required());
|
|
526
532
|
Joi.assert(params.content, Joi.required());
|
|
@@ -528,14 +534,21 @@ class Documents {
|
|
|
528
534
|
Joi.assert(params.type, Joi.string().required());
|
|
529
535
|
|
|
530
536
|
const self = this;
|
|
531
|
-
const
|
|
537
|
+
const reqOpts = {
|
|
532
538
|
headers: {
|
|
533
539
|
'Content-Type': type
|
|
534
540
|
}
|
|
535
541
|
};
|
|
542
|
+
|
|
543
|
+
const onUploadProgress = params.onUploadProgress;
|
|
544
|
+
|
|
545
|
+
if(onUploadProgress) {
|
|
546
|
+
reqOpts.onUploadProgress = onUploadProgress;
|
|
547
|
+
}
|
|
548
|
+
|
|
536
549
|
const apiCall = self._client
|
|
537
|
-
.put(signedUrl, content,
|
|
538
|
-
|
|
550
|
+
.put(signedUrl, content, reqOpts);
|
|
551
|
+
self._returnData(await apiCall);
|
|
539
552
|
return true;
|
|
540
553
|
}
|
|
541
554
|
|
package/dist/bundle.cjs
CHANGED
|
@@ -1055,6 +1055,7 @@ class Documents {
|
|
|
1055
1055
|
* @param {buffer} params.content The content of the file (Buffer)
|
|
1056
1056
|
* @param {string} params.signedUrl The signed URL
|
|
1057
1057
|
* @param {string} params.type The file mime type
|
|
1058
|
+
* @param {string} params.onUploadProgress A callback for the upload progress. It will return a progressEvent.
|
|
1058
1059
|
* @return {Promise<boolean>} True if success
|
|
1059
1060
|
*
|
|
1060
1061
|
* @public
|
|
@@ -1071,8 +1072,13 @@ class Documents {
|
|
|
1071
1072
|
* type: 'application/pdf'
|
|
1072
1073
|
* };
|
|
1073
1074
|
* const retData = await api.user.document.uploadSignedDocument(params);
|
|
1075
|
+
*
|
|
1076
|
+
* onUploadProgress return the progressEvent
|
|
1077
|
+
* - lengthComputable: A Boolean that indicates whether or not the total number of bytes is known.
|
|
1078
|
+
* - loaded: The number of bytes of the file that have been uploaded.
|
|
1079
|
+
* - total: The total number of bytes in the file.
|
|
1074
1080
|
*/
|
|
1075
|
-
async uploadSignedDocument(params) {
|
|
1081
|
+
async uploadSignedDocument(params= {}) {
|
|
1076
1082
|
const { content, signedUrl, type } = params;
|
|
1077
1083
|
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
1078
1084
|
Joi__default["default"].assert(params.content, Joi__default["default"].required());
|
|
@@ -1080,13 +1086,20 @@ class Documents {
|
|
|
1080
1086
|
Joi__default["default"].assert(params.type, Joi__default["default"].string().required());
|
|
1081
1087
|
|
|
1082
1088
|
const self = this;
|
|
1083
|
-
const
|
|
1089
|
+
const reqOpts = {
|
|
1084
1090
|
headers: {
|
|
1085
1091
|
'Content-Type': type
|
|
1086
1092
|
}
|
|
1087
1093
|
};
|
|
1094
|
+
|
|
1095
|
+
const onUploadProgress = params.onUploadProgress;
|
|
1096
|
+
|
|
1097
|
+
if(onUploadProgress) {
|
|
1098
|
+
reqOpts.onUploadProgress = onUploadProgress;
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1088
1101
|
const apiCall = self._client
|
|
1089
|
-
.put(signedUrl, content,
|
|
1102
|
+
.put(signedUrl, content, reqOpts);
|
|
1090
1103
|
self._returnData(await apiCall);
|
|
1091
1104
|
return true;
|
|
1092
1105
|
}
|