UNPKG

next-fileuploader

Version:
2 lines (1 loc) 550 B
import o from"next-connect";import e from"multer";var r=function(r){var t=r.multerConfig,n=e({storage:e[t.storage]({destination:t.des||"./public/uploads",filename:function(o,e,r){return r(null,t.fileName||e.originalname)}})}),a=o({onError:function(o,e,r){r.status(501).json({error:"Sorry something Happened! ".concat(o.message)})},onNoMatch:function(o,e){e.status(405).json({error:"Method '".concat(o.method,"' Not Allowed")})}});a.use(n.array(t.uploadKey||"theFiles"));return{apiRoute:a,config:{api:{bodyParser:!1}}}};export{r as nextFileUploader};