Open vpmalley opened 8 years ago
An existing picture can now be stored. Required: logged in user, existing picture stored in DB, and a CSRF token. The file will be stored locally.
Remaining:
I tried a basic POST
request on /api/0.1/pix/upload
and it's not working at the moment (but it makes sense, your last comment was saying so).
Anyway, would it be possible to have what's needed from the front part so I can implement my part ? Especially:
Thanks
The details of how to upload a picture are on the wiki page to use Postman. In short, a multipart request (form-data) with the picture_id (it must be created) and the picture_file should be sent. The user will need the right to write the image (not implemented yet).
So far, the response contains a json with the picture_id and a url that is actually just an internal path. In the future it will contain an actual url, that is what is left to finish this feature.
TODO: deletion of uploaded file
Done: the upload now returns the entire Picture object.
/!\ changing the endpoint I included the modification of the caption. Now the upload endpoint accepts 3 pair key/value:
id
caption
file
Remaining
@vpmalley 404 Not Found when performing POST request on /api/0.1/upload/pix
(funny thing, I can see the route in /routes
so is that something on my side ?)
I think I know what's wrong: this API returns 404 when the picture (with the id you passed) does not exist.
Did you use the new keys for the parameters? Now you should put the picture id in the form parameters with the id
key (but I am not sure how it behaves when you forget the picture_id
key)
Yes! That was it ! It should be a HTTP 400 to be closer to HTTP standards.
OK, I'll change that
I just fixed that by returning HTTP 400 for a missing picture id. I think the right fix should be to have an endpoint api/{version}/pictures/{pictureId}/upload
, and return 404 if the picture is missing. To be done some day
Use Laravel features to implement file storage, reference it as Link and provide a public URL through this class