Open Allcharles opened 4 years ago
Ok so regions are fully implemented and tested. See https://github.com/QutEcoacoustics/baw-server/commit/2d6a1408fc47e4886443232f981691d06937da24 . See also #497 .
Particularly these specs describe the way in which images can be sent to the API: https://github.com/QutEcoacoustics/baw-server/blob/2d6a1408fc47e4886443232f981691d06937da24/spec/helpers/shared_examples/a_route_that_stores_images.rb
There is no ideal method for sending an image and a record in one request.
if an image and a model are sent they must be sent as form multipart data. This means the model is not sent as JSON as it screws up some of our semantics when fields like notes
are sent. This model is possible but not recommended.
an image can be sent as part of a form multipart request to a model that already exists, this is the recommended approach
Note: we're never going to transmit a multi-megabyte image as base64. just wipe that idea clean out of the realm of possibilities.
Next steps are to ensure project/site pass the same suite of tests as region.
However, the basic process should still allow uploads today - the old site supported it. I'd recommend the two step approach (upload JSON model via API, upload image second as form multipart).
For reference:
a_route_that_stores_images.rb
specsa_route_that_stores_images.rb
specsa_route_that_stores_images.rb
specs
Missing the ability to create a project/site, or update an existing project/site, with an image input. This image input could potentially be achieved by setting
Content-Type
to a Mime Multipart or similar type. Currently the route potentially accepts only base64 encoding?Routes:
POST
/projects
POST
/sites
POST
/projects/:projectId/sites
PUT/PATCH
/projects/:id
PUT/PATCH
/sites/:id
PUT/PATCH
/projects/:projectId/sites/:siteId