I have to design a REST API to support a locationBasedService Application, the location is the main resource in the system with the following services :
- Create a location by filling a form, location data includes name, coordinates, description and image
- Create more than one location by uploading a JSON file. Image will be null in this case
- Update a location. Location data will be edited from a form similar to the one from which it was created
My main problem is related to the file part of the location data. I read a lot of questions related to this and I came to the following two designs:
encode the file data as base64 and send the file part of the JSON data, (limitations: image size), the rest API will be as follows:
/lbs/admin/locations
PUT - for form creation/lbs/admin/locations
POST - for update/lbs/admin/fileupload/location
POST for file creationthe second design considers sending two requests to the server, the first one to
/lbs/admin/location
with [PUT] where all data except file will be sent, the response will include the id of the created location, where another request will be [POSTED] to/lbs/admin/location/{id}
with file data to be created
Now, do you have any better design and if I consider the second approach, how can I design the update location logic?