nodejs删除图片成功还是会报错,大锅们,为什么啊
f(req.file) {
const index = formData.src.indexOf(':3000')
const url = formData.src.substring(index+5)
fs.unlink(path.join(__dirname,`img/${url}`),err => {
console.log(err);
res.status(500)
})
formData.src = src
let img = fs.readFileSync(path.join(__dirname,`./img/${urlStr}`))
let newstr = cutOutStr(urlStr)
let newImg = path.join(__dirname,`./img/${newstr}.png`)
let textShaop = await sharp({text:{text:'永华家具',width:70,dpi:80,rgba:true}}).png().tint({ r: 15, g: 105, b: 205 }).composite([{input:Buffer.from([255, 255, 255, 60]),raw: { width: 1, height: 1, channels: 4 },tile: true,blend: 'dest-in'}]).rotate(30).toBuffer()
await sharp(img).composite([{input:textShaop,blend: 'atop', left: 130, top: 70}]).resize(300, 180, {fit: 'cover',}).toFile(newImg)
fs.unlink(path.join(__dirname,`./img/${urlStr}`),errs => {
console.log(errs);
res.status(500)
})
}
为啥呀,大锅们