u
This commit is contained in:
parent
8ce54673c2
commit
dd988d4a79
@ -23,7 +23,8 @@ module.exports = {
|
||||
|
||||
// 虽然可以把本方法写成 async 的,并且在这里调用 wo.ipfsStore.ipfs.add(file.stream) 来获取 cid,但是最后在本地存成的文件是 0字节的。因此还是用个随机数吧。
|
||||
// 或者,干脆利用这个缺陷,直接提交到 ipfs,在本地就留着0字节文件不要使用就好了。同时,在 api.receiveFile 里,就要相应的直接返回 IPFS 网址给前端。
|
||||
const filename = `${Date.now()}-${crypto.randomBytes(16).toString('hex')}${path.extname(file.originalname)}`
|
||||
const filename =
|
||||
`${Date.now()}-${crypto.randomBytes(16).toString('hex')}` + (path.extname(file.originalname) || `.${file?.mimetype?.split?.('/')?.[1]}`)
|
||||
//const _passtokenSource = webtoken.verifyToken(req.headers._passtoken) || {}
|
||||
//const filename = `${req.path.replace(/^\/api\d*/, '')}_${_passtokenSource.usid}_${Date.now()}${fileNameExtension}` // 如果最终 filename 含有 / (例如当 req.path 为 Who/todo),则必须已经存在该目录,否则在这里就出错,不会进入下面流程。
|
||||
cb(null, filename)
|
||||
|
Loading…
Reference in New Issue
Block a user