From e722b2dca205d5aaa2da8cbf66ab244273ba815f Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 3 Apr 2022 16:19:04 +0800 Subject: [PATCH] rename envi to envar --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 55600a2..53378a9 100644 --- a/index.js +++ b/index.js @@ -10,13 +10,13 @@ module.exports = { storage: multer.diskStorage({ destination (req, file, cb) { // 如果直接提供字符串,multer会负责创建该目录。如果提供函数,你要负责确保该目录存在。 - cb(null, wo?.envi?.File_Store) // 目录是相对于本应用的入口js的,即相对于 server.js 的位置。 + cb(null, wo?.envar?.File_Store) // 目录是相对于本应用的入口js的,即相对于 server.js 的位置。 }, filename (req, file, cb) { // 注意,req.body 也许还没有信息,因为这取决于客户端发送body和file的顺序。必要的信息请从 req.headers 传递,例如 _passtoken(在multer时,尚未进入路由,不存在已装好的 _passtokenSource) const fileNameExtension = path.extname(file.originalname) const filename = `${Date.now()}_${crypto.randomBytes(16).toString('hex')}${fileNameExtension}` - //const _passtokenSource = webtoken.verifyToken(req.headers._passtoken, wo.envi.tokenKey) || {} + //const _passtokenSource = webtoken.verifyToken(req.headers._passtoken, wo.envar.tokenKey) || {} //const filename = `${req.path.replace(/^\/api\d*/, '')}_${_passtokenSource.uuid}_${Date.now()}${fileNameExtension}` // 如果最终 filename 含有 / (例如当 req.path 为 Who/todo),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。 cb(null, filename) },