mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 04:51:31 +08: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 GET = 'get', POST = 'post', PUT = 'put', PATCH = 'patch', DELETE = 'delete'; | ||||
| const uploadMiddleware = multer({ | ||||
| 
 | ||||
| const multerOptions = { | ||||
|     fileFilter: (req, file, cb) => { | ||||
|         // 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.
 | ||||
|         file.originalname = Buffer.from(file.originalname, "latin1").toString("utf-8"); | ||||
|         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) { | ||||
|     uploadMiddleware(req, res, function (err) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam