Read Files

Let’s implement the necessary endpoint to retrieve the uploaded files from the server.

In this lesson, we’ll implement the essential endpoints that allow web applications to perform the basic operations that a user expects. Just to review, these basic operations are called CRUD (create, read, update, and delete) operations.

We have already implemented the create operation, which is the upload functionality. So now, we’ll implement the necessary read endpoints.

  • We’ll get all the files uploaded by a user.

  • We’ll get a file uploaded by a user with its ID.

  • We’ll search files uploaded by a user using their name.

Get all files

To retrieve all the files, we need to make sure the following is complete:

  • The user should be authenticated so that the guests can’t see each other’s files.

  • Each user should be able to retrieve their own files only, not the files of others.

We can implement those required actions like this:

Get hands-on with 1200+ tech skills courses.