vpmalley / jetlag

Bases of a future travel blog platform
MIT License
1 stars 0 forks source link

Implement picture storage #27

Open vpmalley opened 8 years ago

vpmalley commented 8 years ago

Use Laravel features to implement file storage, reference it as Link and provide a public URL through this class

vpmalley commented 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.

vpmalley commented 8 years ago

Remaining:

Vallenain commented 8 years ago

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

vpmalley commented 8 years ago

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.

vpmalley commented 8 years ago

TODO: deletion of uploaded file

vpmalley commented 7 years ago

Done: the upload now returns the entire Picture object.

vpmalley commented 7 years ago

/!\ changing the endpoint I included the modification of the caption. Now the upload endpoint accepts 3 pair key/value:

vpmalley commented 7 years ago

Remaining

Vallenain commented 7 years ago

@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 ?)

vpmalley commented 7 years ago

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)

Vallenain commented 7 years ago

Yes! That was it ! It should be a HTTP 400 to be closer to HTTP standards.

vpmalley commented 7 years ago

OK, I'll change that

vpmalley commented 7 years ago

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