{"record":{"id":"e4703617a5f79a7a","repo":"RocketChat/Rocket.Chat","slug":"error-direct-message-file-upload-not-allowed","errorCode":"error-direct-message-file-upload-not-allowed","errorMessage":"File sharing not allowed in direct messages.","messagePattern":"File sharing not allowed in direct messages\\.","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts","lineNumber":173,"sourceCode":"\n\t\tconst room = file.rid ? await Rooms.findOneById(file.rid) : undefined;\n\t\tif (!isFederationUpload && !room) {\n\t\t\treturn false;\n\t\t}\n\t\tconst directMessageAllowed = settings.get('FileUpload_Enabled_Direct');\n\t\tconst fileUploadAllowed = settings.get('FileUpload_Enabled');\n\t\tif (!isFederationUpload && room && user?.type !== 'app' && (await canAccessRoomAsync(room, user, file)) !== true) {\n\t\t\treturn false;\n\t\t}\n\t\tconst language = user?.language || 'en';\n\t\tif (!fileUploadAllowed) {\n\t\t\tconst reason = i18n.t('FileUpload_Disabled', { lng: language });\n\t\t\tthrow new Meteor.Error('error-file-upload-disabled', reason);\n\t\t}\n\n\t\tif (room && !directMessageAllowed && room.t === 'd') {\n\t\t\tconst reason = i18n.t('File_not_allowed_direct_messages', { lng: language });\n\t\t\tthrow new Meteor.Error('error-direct-message-file-upload-not-allowed', reason);\n\t\t}\n\n\t\t// -1 maxFileSize means there is no limit\n\t\tif (maxFileSize > -1 && (file.size || 0) > maxFileSize) {\n\t\t\tconst reason = i18n.t('File_exceeds_allowed_size_of_bytes', {\n\t\t\t\tsize: filesize(maxFileSize),\n\t\t\t\tlng: language,\n\t\t\t});\n\t\t\tthrow new Meteor.Error('error-file-too-large', reason);\n\t\t}\n\n\t\tif (!settings.get('E2E_Enable_Encrypt_Files') && isE2EEUpload(file)) {\n\t\t\tconst reason = i18n.t('Encrypted_file_not_allowed', { lng: language });\n\t\t\tthrow new Meteor.Error('error-invalid-file-type', reason);\n\t\t}\n\n\t\t// E2EE files should be of type application/octet-stream. no information about them should be disclosed on upload if they are encrypted\n\t\tif (isE2EEUpload(file)) {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts#L155-L191","documentation":"Error \"File sharing not allowed in direct messages.\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/lib/media/file-upload/lib/FileUpload.ts:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enable FileUpload_Enabled_Direct in Administration > File Upload to allow file sharing in direct messages.","Send the file in a channel or private group instead of a direct message."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}