fix: Add application/octet-stream as a valid mimetype for docx uploads (#2105)
* fix: Add application/octet-stream as a valid mimetype for docx uploads * fix: Include application/octet-stream in frontend filter fix: Add file size and file type guards * Validate .docx extension in files with application/octet-stream mimetype * refactor: Move MAXIMUM_IMPORT_SIZE to an optional environment config fix: Add file size check on server too Co-authored-by: Saumya Pandey <sp160899@gmail.com>
This commit is contained in:
@ -5,6 +5,7 @@ import { subtractDate } from "../../shared/utils/date";
|
||||
import documentCreator from "../commands/documentCreator";
|
||||
import documentImporter from "../commands/documentImporter";
|
||||
import documentMover from "../commands/documentMover";
|
||||
import env from "../env";
|
||||
import {
|
||||
NotFoundError,
|
||||
InvalidRequestError,
|
||||
@ -1179,6 +1180,10 @@ router.post("documents.import", auth(), async (ctx) => {
|
||||
const file: any = Object.values(ctx.request.files)[0];
|
||||
ctx.assertPresent(file, "file is required");
|
||||
|
||||
if (file.size > env.MAXIMUM_IMPORT_SIZE) {
|
||||
throw new InvalidRequestError("The selected file was too large to import");
|
||||
}
|
||||
|
||||
ctx.assertUuid(collectionId, "collectionId must be an uuid");
|
||||
if (parentDocumentId) {
|
||||
ctx.assertUuid(parentDocumentId, "parentDocumentId must be an uuid");
|
||||
|
Reference in New Issue
Block a user