mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	add TRILIUM_NO_UPLOAD_LIMIT to disable the upload limit, #3164
This commit is contained in:
		
							parent
							
								
									4961d9bb89
								
							
						
					
					
						commit
						d9dac00a01
					
				| @ -197,17 +197,23 @@ function route(method, path, middleware, routeHandler, resultHandler, transactio | |||||||
| const MAX_ALLOWED_FILE_SIZE_MB = 250; | const MAX_ALLOWED_FILE_SIZE_MB = 250; | ||||||
| 
 | 
 | ||||||
| const GET = 'get', POST = 'post', PUT = 'put', PATCH = 'patch', DELETE = 'delete'; | const GET = 'get', POST = 'post', PUT = 'put', PATCH = 'patch', DELETE = 'delete'; | ||||||
| const uploadMiddleware = multer({ | 
 | ||||||
|  | const multerOptions = { | ||||||
|     fileFilter: (req, file, cb) => { |     fileFilter: (req, file, cb) => { | ||||||
|         // UTF-8 file names are not well decoded by multer/busboy, so we handle the conversion on our side.
 |         // UTF-8 file names are not well decoded by multer/busboy, so we handle the conversion on our side.
 | ||||||
|         // See https://github.com/expressjs/multer/pull/1102.
 |         // See https://github.com/expressjs/multer/pull/1102.
 | ||||||
|         file.originalname = Buffer.from(file.originalname, "latin1").toString("utf-8"); |         file.originalname = Buffer.from(file.originalname, "latin1").toString("utf-8"); | ||||||
|         cb(null, true); |         cb(null, true); | ||||||
|     }, |  | ||||||
|     limits: { |  | ||||||
|         fileSize: MAX_ALLOWED_FILE_SIZE_MB * 1024 * 1024 |  | ||||||
|     } |     } | ||||||
| }).single('upload'); | }; | ||||||
|  | 
 | ||||||
|  | if (!process.env.TRILIUM_NO_UPLOAD_LIMIT) { | ||||||
|  |     multerOptions.limits = { | ||||||
|  |         fileSize: MAX_ALLOWED_FILE_SIZE_MB * 1024 * 1024 | ||||||
|  |     }; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const uploadMiddleware = multer(multerOptions).single('upload'); | ||||||
| 
 | 
 | ||||||
| const uploadMiddlewareWithErrorHandling = function (req, res, next) { | const uploadMiddlewareWithErrorHandling = function (req, res, next) { | ||||||
|     uploadMiddleware(req, res, function (err) { |     uploadMiddleware(req, res, function (err) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam