How to handle mime types, file extension and magic number on file upload, renaming and file download?

I am writing a simple server for file uploading. I want to be able to rename uploaded files (including the file extension) and download files.
For validating the file to upload my plan was to check if the mime type, the file extension and … Continue reading How to handle mime types, file extension and magic number on file upload, renaming and file download?