mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: auto cleanup uploaded files (#818)
This commit is contained in:
10 files changed
+40
-24
No files matched your search
@@ -124,10 +124,10 @@ class ImportHojHandler extends Handler {
|
||||
}
|
||||
|
||||
async post({ domainId }) {
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
const stat = await fs.stat(this.request.files.file.filepath);
|
||||
if (stat.size > 128 * 1024 * 1024) throw new ValidationError('file', 'File too large');
|
||||
await this.fromFile(domainId, this.request.files.file.filepath);
|
||||
const file = this.request.files.file;
|
||||
if (!file) throw new ValidationError('file');
|
||||
if (file.size > 128 * 1024 * 1024) throw new ValidationError('file', 'File too large');
|
||||
await this.fromFile(domainId, file.filepath);
|
||||
this.response.redirect = this.url('problem_main');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user