polgo-upload-kit 1.1.6 → 1.1.8
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/package.json +1 -1
- package/src/polgoUploadClient.js +8 -4
package/package.json
CHANGED
package/src/polgoUploadClient.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// src/index.js
|
|
2
1
|
import axios from "axios";
|
|
3
2
|
|
|
4
3
|
class PolgoUploadClient {
|
|
@@ -31,14 +30,19 @@ class PolgoUploadClient {
|
|
|
31
30
|
|
|
32
31
|
try {
|
|
33
32
|
const response = await axios.post(finalUrl, form, {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${this.token}`,
|
|
35
|
+
},
|
|
34
36
|
onUploadProgress: (progressEvent) => {
|
|
35
|
-
const
|
|
37
|
+
const percentCompleted = Math.round(
|
|
36
38
|
(progressEvent.loaded * 100) / progressEvent.total
|
|
37
39
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
if (typeof onProgress === "function") {
|
|
41
|
+
onProgress(percentCompleted);
|
|
42
|
+
}
|
|
40
43
|
},
|
|
41
44
|
});
|
|
45
|
+
|
|
42
46
|
return response.data;
|
|
43
47
|
} catch (error) {
|
|
44
48
|
console.error("Erro ao fazer upload do arquivo:", error.message);
|