feat: allow fps zipfile

This commit is contained in:
undefined committed 2020-09-04 12:51:15 +08:00
1 parent efa3faea5d
commit c0489546b8
5 files changed
+17 -51

No files matched your search

+14 -1
View File
@@ -19,8 +19,21 @@ class FpsProblemImportHandler extends Handler {
if (ufid) {
const stream = await file.get(ufid);
const buf = await streamToBuffer(stream);
let input = buf.toString();
try {
await xml2js.parseStringPromise(input);
} catch (e) {
const zip = new AdmZip(buf);
const entries = zip.getEntries();
for (const entry of entries) {
if (entry.entryName.endsWith('.xml')) {
input = entry.getData().toString();
break;
}
}
}
// @ts-ignore
await this.post({ domainId, input: buf.toString() });
await this.post({ domainId, input });
await file.del(ufid);
} else this.response.template = 'problem_import_fps.html';
}