Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
iiop123 committed Nov 14, 2022
1 parent 1f26bbd commit b4a8703
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ router.post(
let form=req.body.formData()
let out=[]
let img=(await form).getAll('img')
const img_check=/^[\s\S]*\.(jpg|jpeg|png|gif|ico|svg)$/
const img_check=new RegExp("(.*?)\.(png|jpe?g|gif|bmp|psd|tiff|tga|eps)","i")
for (let i = 0; i < img.length; i++) {
if (img_check.test(img[i].name)) {
let url=await randomString()
Expand All @@ -111,12 +111,14 @@ router.post(
}
})
out.push(req.url+'/img/'+url)
res.body = {src:out}
}else{
res.status=400
res.body={name:img[i].name,err:'非图片文件'}
out='非图片文件'
break
}
}}
}
res.body={src:out}
}
);
router.get('/api/img/:p', async ({req,res})=>{
let body=await LINK.get(req.params.p,{cacheTtl:864000,type:"stream"})
Expand Down

0 comments on commit b4a8703

Please sign in to comment.