Back to Developer Roadmap

File Uploads

src/data/question-groups/backend/content/file-uploads.md

4.01.0 KB
Original Source

From a backend developer perspective, the following considerations should be taken into account when handling file uploads regardless of the programming language you’re using:

  • Perform server-side validations. Validate that the size of your file is within range, and that the file is of the required type. You can check this OWASP guide for more details.
  • Use secure channels. Make sure the file upload is done through an HTTPS connection.
  • Avoid name collision. Rename the file ensuring the new filename is unique within your system. Otherwise this can lead to application errors by not being able to save the uploaded files.
  • Keep metadata about your files. Store it in your database or somewhere else, but make sure to keep track of it, so you can provide extra information to your users. Also, if you’re renaming the files for security and to avoid name collisions, keep track of the original filename in case the file needs to be downloaded back by the user.