rename envi to envar
This commit is contained in:
parent
0a4cf537d1
commit
e722b2dca2
4
index.js
4
index.js
@ -10,13 +10,13 @@ module.exports = {
|
|||||||
storage: multer.diskStorage({
|
storage: multer.diskStorage({
|
||||||
destination (req, file, cb) {
|
destination (req, file, cb) {
|
||||||
// 如果直接提供字符串,multer会负责创建该目录。如果提供函数,你要负责确保该目录存在。
|
// 如果直接提供字符串,multer会负责创建该目录。如果提供函数,你要负责确保该目录存在。
|
||||||
cb(null, wo?.envi?.File_Store) // 目录是相对于本应用的入口js的,即相对于 server.js 的位置。
|
cb(null, wo?.envar?.File_Store) // 目录是相对于本应用的入口js的,即相对于 server.js 的位置。
|
||||||
},
|
},
|
||||||
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, 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),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。
|
//const filename = `${req.path.replace(/^\/api\d*/, '')}_${_passtokenSource.uuid}_${Date.now()}${fileNameExtension}` // 如果最终 filename 含有 / (例如当 req.path 为 Who/todo),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。
|
||||||
cb(null, filename)
|
cb(null, filename)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user