默认文件名 '时刻_随机数' 改为 '时刻-随机数'
This commit is contained in:
		
							parent
							
								
									3625b6cc40
								
							
						
					
					
						commit
						4d377af964
					
				@ -14,7 +14,7 @@ module.exports = {
 | 
				
			|||||||
      filename (req, file, cb) {
 | 
					      filename (req, file, cb) {
 | 
				
			||||||
        // 注意,req.body 也许还没有信息,因为这取决于客户端发送body和file的顺序。必要的信息请从 req.headers 传递,例如 _passtoken(在multer时,尚未进入路由,不存在已装好的 _passtokenSource)
 | 
					        // 注意,req.body 也许还没有信息,因为这取决于客户端发送body和file的顺序。必要的信息请从 req.headers 传递,例如 _passtoken(在multer时,尚未进入路由,不存在已装好的 _passtokenSource)
 | 
				
			||||||
        const fileNameExtension = path.extname(file.originalname)
 | 
					        const fileNameExtension = path.extname(file.originalname)
 | 
				
			||||||
        const filename = `${Date.now()}_${crypto.randomBytes(16).toString('hex')}${fileNameExtension}`
 | 
					        const filename = `${Date.now()}-${crypto.randomBytes(16).toString('hex')}${fileNameExtension}`
 | 
				
			||||||
        //const _passtokenSource = webtoken.verifyToken(req.headers._passtoken) || {}
 | 
					        //const _passtokenSource = webtoken.verifyToken(req.headers._passtoken) || {}
 | 
				
			||||||
        //const filename = `${req.path.replace(/^\/api\d*/, '')}_${_passtokenSource.usid}_${Date.now()}${fileNameExtension}` // 如果最终 filename 含有 / (例如当 req.path 为 Who/todo),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。
 | 
					        //const filename = `${req.path.replace(/^\/api\d*/, '')}_${_passtokenSource.usid}_${Date.now()}${fileNameExtension}` // 如果最终 filename 含有 / (例如当 req.path 为 Who/todo),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。
 | 
				
			||||||
        cb(null, filename)
 | 
					        cb(null, filename)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user