{"record":{"id":"fdab5547f3926004","repo":"RocketChat/Rocket.Chat","slug":"error-no-file-uploaded","errorCode":"error-no-file-uploaded","errorMessage":"No file was uploaded","messagePattern":"No file was uploaded","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":281,"sourceCode":"\t},\n);\n\nAPI.v1.addRoute(\n\t'rooms.media/:rid',\n\t{ authRequired: true },\n\t{\n\t\tasync post() {\n\t\t\tif (!(await canAccessRoomIdAsync(this.urlParams.rid, this.userId))) {\n\t\t\t\treturn API.v1.forbidden();\n\t\t\t}\n\n\t\t\tconst { file, fields } = await MultipartUploadHandler.parseRequest(this.incoming, {\n\t\t\t\tfield: 'file',\n\t\t\t\tmaxSize: settings.get<number>('FileUpload_MaxFileSize'),\n\t\t\t});\n\n\t\t\tif (!file) {\n\t\t\t\tthrow new Meteor.Error('error-no-file-uploaded', 'No file was uploaded');\n\t\t\t}\n\n\t\t\tconst expiresAt = new Date();\n\t\t\texpiresAt.setHours(expiresAt.getHours() + 24);\n\n\t\t\tlet content;\n\n\t\t\tif (fields.content) {\n\t\t\t\ttry {\n\t\t\t\t\tcontent = JSON.parse(fields.content);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(e);\n\t\t\t\t\tthrow new Meteor.Error('invalid-field-content');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst details = {\n\t\t\t\tname: file.filename,","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/rooms.ts#L263-L299","documentation":"Thrown by POST rooms.upload/:rid (multipart) when MultipartUploadHandler.parseRequest returns no 'file' part. The handler expects a multipart form with a 'file' field capped by FileUpload_MaxFileSize. Reaching this branch means the request either had no file field, failed file-size handling, or was not multipart at all.","triggerScenarios":"POST /api/v1/rooms.upload/:rid with a JSON body instead of multipart/form-data; multipart request whose file field is named something other than 'file'; empty form; file rejected upstream of the handler so 'file' is undefined.","commonSituations":"Client forgetting to set Content-Type: multipart/form-data; using 'attachment' or 'upload' as the field name; file uploads disabled or FileUpload_MaxFileSize set to 0; proxy/gateway stripping the multipart boundary.","solutions":["Send the request as multipart/form-data with a part literally named 'file'.","In axios/fetch/Postman, use FormData and append('file', blob, name) — do not JSON.stringify the body.","Confirm FileUpload_MaxFileSize in admin settings is greater than your file size and > 0.","If using the resumable/Streamer flow for large files, use rooms.mediaConfirm instead of rooms.upload."],"exampleFix":"// before (wrong: JSON body)\nawait rest.post(`/api/v1/rooms.upload/${rid}`, { file: base64 });\n\n// after (multipart with field 'file')\nconst form = new FormData();\nform.append('file', fileBlob, fileBlob.name);\nawait rest.post(`/api/v1/rooms.upload/${rid}`, form);","handlingStrategy":"validation","validationCode":"function buildUploadForm(file: Blob, fields?: Record<string, string>): FormData {\n  if (!(file instanceof Blob)) throw new TypeError('file must be a Blob/File');\n  const form = new FormData();\n  form.append('file', file, (file as File).name || 'upload.bin');\n  for (const [k, v] of Object.entries(fields ?? {})) form.append(k, v);\n  return form;\n}","typeGuard":"function isMultipartReady(form: FormData): boolean {\n  return form.has('file');\n}","tryCatchPattern":"try {\n  await rest.post(`/api/v1/rooms.upload/${rid}`, form, { headers: form.getHeaders?.() });\n} catch (e) {\n  if (isMeteorError(e, 'error-no-file-uploaded')) {\n    // verify field name is 'file' and Content-Type is multipart/form-data\n  } else throw e;\n}","preventionTips":["Always use FormData and append('file', ...).","Let the HTTP library set Content-Type with the boundary — don't set it manually.","Confirm FileUpload_MaxFileSize > file.size before sending."],"tags":["file-upload","multipart","rest-api","rooms"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}