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);
|
||||
|
||||
try {
|
||||
// Отправить ZIP на бэкенд
|
||||
// Отправить ZIP на бэкенд (multipart — бэкенд ищет boundary + PK magic)
|
||||
var zipResp = await new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', UNZIP_URL);
|
||||
@@ -321,7 +321,9 @@ async function addZipFile(file) {
|
||||
xhr.onerror = function() { reject(new Error('Сеть')); };
|
||||
xhr.ontimeout = function() { reject(new Error('Таймаут')); };
|
||||
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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user