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:
- 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).
- Send the UUID back to client.
- 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.
- Now there will be another API call (API_2) to start the upload process for the previously generated UUID.
- If the upload succeeds, Update the Status for the UUID passed.
- Store the Uploaded file in a File Storage System like AWS S3.
- Store the S3 Bucket location and path of the file in the database for the UUID.
- 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.
- User can click download upon which the DB will be quried to get File location for the UUID of the item.
- S3 Bucket and Path location of the file will be used to retrieve the file.