Refuse upload on routes in ExpressJS

I have been working with ExpressJS to facilitate file uploads, but as far as I can see you could upload a file to any route regardless of it it handles it or not.

Say I have

app.post('/photos/upload', photos.upload);

I know I want a photo upload via that route so I can handle it, but what if someone uploads files to other routes? All those files are going to be written to the server, but not handled.

Is there a way to refuse uploads on all routes apart from ones I actually want files uploaded to?

Thanks

What you're doing right now something like:

app.use(express.bodyParser())

which includes express.multipart() that handles file uploads. You'll just want to split this up:

app.use(express.json())
app.use(express.urlencoded())

app.post('/photos/upload', express.multipart(), photos.upload)