This commit is contained in:
Tom Moor
2022-09-14 11:04:38 +01:00
parent e1e7f1b97d
commit 607a795dd0
3 changed files with 11 additions and 8 deletions

View File

@@ -1068,9 +1068,12 @@ router.post("documents.import", auth(), async (ctx) => {
throw InvalidRequestError("Request type must be multipart/form-data");
}
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
const file = Object.values(ctx.request.files)[0];
assertPresent(file, "file is required");
const file = ctx.request.files
? Object.values(ctx.request.files)[0]
: undefined;
if (!file) {
throw InvalidRequestError("Request must include a file parameter");
}
if (env.MAXIMUM_IMPORT_SIZE && file.size > env.MAXIMUM_IMPORT_SIZE) {
throw InvalidRequestError(