Let's review the changes we should do on the API level to support file uploads. We will need a new table on the database to store the relations between the images uploaded and the users. As we are creating a new table on the database, we will also need a table gateway object to access the data. Finally, we are going to modify the create()
method to handle the code for the status text and add the code for the image upload.
The requirements for the API are the same in terms of HTTP methods. The only thing we are going to change is the way we process the data in the create()
method. Essentially, when a request arrives to the create()
method, we should try to detect if we are fulfilling a request to create a new status entry or are trying to post a new image.
The create()
method will inspect the contents of the $data
parameter, searching for an entry on the array. If we find the key status in the array, we will call it the createStatus()
method, which contains the code...