mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
feat: allow fps zipfile
This commit is contained in:
1 parent
efa3faea5d
commit
c0489546b8
5 files changed
+17
-51
No files matched your search
@@ -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';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user