System Design: Upload Documents

Hi Any pointers for this question if asked in an interview? How to approach and implementation options.

Requirement: User can upload any document (pdf, gif, png, excel, csv etc... )
File Size Limitation: Upto 10 MB.
File Encryption at Rest.
User should be able to view/update/delete uploaded documents.

My idea:

  1. First make an API call (API_1) with file metadata (file name, filesize, fileextension, User,etc) and Add it to a DB table (postgresql).
    Keep the status of the Upload as Pending/Uploading. The entry will have unique id (UUID).
  2. Send the UUID back to client.
  3. If there already exists a file for the User with the same file name and file type (extension) in the database, notify User about that.
  4. Now there will be another API call (API_2) to start the upload process for the previously generated UUID.
  5. If the upload succeeds, Update the Status for the UUID passed.
  6. Store the Uploaded file in a File Storage System like AWS S3.
  7. Store the S3 Bucket location and path of the file in the database for the UUID.
  8. Using AWS KMS Keys we will encrypt the file at rest.

Retrieval:
User will be able to see all the Uploaded files in the UI.

  1. User can click download upon which the DB will be quried to get File location for the UUID of the item.
  2. S3 Bucket and Path location of the file will be used to retrieve the file.
Comments (5)