The short version
Check every upload's size and type on the server, and check the file's first bytes as well as its extension and MIME type, because the MIME type comes from the client and is easy to fake.
Store uploads in private object storage like S3 instead of on the server that runs your app, and scan each file for malware in a background worker before anyone can download it.
Rename every upload to a random ID and re-encode images to strip metadata such as the GPS coordinates that phone photos often carry.
Serve files through signed URLs that expire, for example after an hour, and only hand one out after checking that the user asking owns the file.
Log and rate-limit both uploads and downloads, and repeat the size and type checks in the browser for fast feedback, since only the server-side checks keep an attacker out.
To secure file uploads in an API, check each file's size and type on the server, store accepted files in object storage like S3 instead of on your app server, scan them for malwareβ¦