v1.0.178: fix unzip — xhr.send(file) → FormData. Бэкенд ждёт multipart (ищет \r\n\r\n + PK magic), а не сырой файл.
This commit is contained in:
+4
-2
@@ -312,7 +312,7 @@ async function addZipFile(file) {
|
|||||||
render(state);
|
render(state);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Отправить ZIP на бэкенд
|
// Отправить ZIP на бэкенд (multipart — бэкенд ищет boundary + PK magic)
|
||||||
var zipResp = await new Promise(function(resolve, reject) {
|
var zipResp = await new Promise(function(resolve, reject) {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', UNZIP_URL);
|
xhr.open('POST', UNZIP_URL);
|
||||||
@@ -321,7 +321,9 @@ async function addZipFile(file) {
|
|||||||
xhr.onerror = function() { reject(new Error('Сеть')); };
|
xhr.onerror = function() { reject(new Error('Сеть')); };
|
||||||
xhr.ontimeout = function() { reject(new Error('Таймаут')); };
|
xhr.ontimeout = function() { reject(new Error('Таймаут')); };
|
||||||
xhr.timeout = 60000;
|
xhr.timeout = 60000;
|
||||||
xhr.send(file);
|
var fd = new FormData();
|
||||||
|
fd.append('files', file);
|
||||||
|
xhr.send(fd);
|
||||||
});
|
});
|
||||||
if (!zipResp.ok || !zipResp.files) throw new Error('unzip failed');
|
if (!zipResp.ok || !zipResp.files) throw new Error('unzip failed');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user