Hook
More breakout videos from this creator.
For today's software engineering interview, design a file upload service like Google Drive. Okay, that's easy. I would just use a server and a database. A user passes a file plus their user ID to my database so I can validate them. Then we extract some metadata about their file and store it all in our database to retrieve easily later. You sure storing the files themselves in a relational database like PostgreSQL is the best approach. All right, that's a good point. How about this? We store information about the file in PostgreSQL so we can easily query through things like how many files, does one user have and one of the names of those files, but we store the files themselves in S3. This is much better for storing objects like files. So the entire file is going to be passing through your API and servers on every request. Can you think of a more efficient way to do that? That's a good point. Instead of having files passed through our server, we'll use S3 directly. When they want to upload something, we'll first generate a presigned upload URL in S3. Then we'll give that URL back to the user and they upload the file directly to that URL, so their file never actually goes through our servers. Okay, that looks pretty good. How about for downloads? Downloads will work almost the same exact way. When they want to get a file, we'll first look in the post-grest table, check the metadata, then we'll get the file ID for where that file is stored in S3. We'll generate a presigned URL, then we'll return that URL to the user and they download it directly from S3. So the files never pass through our server.