@karpeleslab/klbfw 0.2.11 → 0.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/package.json +1 -1
- package/upload.js +23 -6
package/package.json
CHANGED
package/upload.js
CHANGED
|
@@ -459,7 +459,7 @@ module.exports.upload = (function () {
|
|
|
459
459
|
params.filename = up.file.name;
|
|
460
460
|
params.size = up.file.size;
|
|
461
461
|
params.lastModified = up.file.lastModified / 1000;
|
|
462
|
-
params.type = up.file.type;
|
|
462
|
+
params.type = up.file.type || "application/octet-stream";
|
|
463
463
|
|
|
464
464
|
// Initialize upload with the server
|
|
465
465
|
rest.rest(up.path, "POST", params, up.context)
|
|
@@ -497,7 +497,7 @@ module.exports.upload = (function () {
|
|
|
497
497
|
"POST",
|
|
498
498
|
"uploads=",
|
|
499
499
|
"",
|
|
500
|
-
{"Content-Type": up.file.type, "X-Amz-Acl": "private"},
|
|
500
|
+
{"Content-Type": up.file.type || "application/octet-stream", "X-Amz-Acl": "private"},
|
|
501
501
|
up.context
|
|
502
502
|
)
|
|
503
503
|
.then(response => response.text())
|
|
@@ -609,9 +609,18 @@ module.exports.upload = (function () {
|
|
|
609
609
|
up.context
|
|
610
610
|
)
|
|
611
611
|
.then(response => {
|
|
612
|
+
// Verify the response is successful
|
|
613
|
+
if (!response.ok) {
|
|
614
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
615
|
+
}
|
|
612
616
|
// Store ETag for this part (needed for completion)
|
|
613
|
-
|
|
614
|
-
|
|
617
|
+
const etag = response.headers.get("ETag");
|
|
618
|
+
// Read response body to ensure request completed
|
|
619
|
+
return response.text().then(() => etag);
|
|
620
|
+
})
|
|
621
|
+
.then(etag => {
|
|
622
|
+
up.b[partNumber] = etag;
|
|
623
|
+
|
|
615
624
|
// Update progress and continue processing
|
|
616
625
|
sendProgress();
|
|
617
626
|
upload.run();
|
|
@@ -629,7 +638,7 @@ module.exports.upload = (function () {
|
|
|
629
638
|
function uploadPutPart(up, partNumber, startByte, data) {
|
|
630
639
|
// Set up headers
|
|
631
640
|
const headers = {
|
|
632
|
-
"Content-Type": up.file.type
|
|
641
|
+
"Content-Type": up.file.type || "application/octet-stream"
|
|
633
642
|
};
|
|
634
643
|
|
|
635
644
|
// Add Content-Range header for multipart PUT
|
|
@@ -645,9 +654,17 @@ module.exports.upload = (function () {
|
|
|
645
654
|
headers: headers,
|
|
646
655
|
})
|
|
647
656
|
.then(response => {
|
|
657
|
+
// Verify the response is successful
|
|
658
|
+
if (!response.ok) {
|
|
659
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
660
|
+
}
|
|
661
|
+
// Read response body to ensure request completed
|
|
662
|
+
return response.text();
|
|
663
|
+
})
|
|
664
|
+
.then(() => {
|
|
648
665
|
// Mark part as done
|
|
649
666
|
up.b[partNumber] = "done";
|
|
650
|
-
|
|
667
|
+
|
|
651
668
|
// Update progress and continue processing
|
|
652
669
|
sendProgress();
|
|
653
670
|
upload.run();
|