Courses

How to Create Laravel 7 API

Uploading files via API

Previous: Finishing CRUD: Update, Delete and Resource Controller
avatar

I am having trouble to do the same for update with PUT/PATCH method. Would it be better to create separate upload and delete image routes? Anyway let's suppose is necessary to create and update the category with both name and file in case is compulsory.

Moreover, have you got any article/video that explains how to create the route to get that file in API?

Thanks a lot!!

avatar

Wow, so many questions in one comment. Well, it's your personal preference how to implement it: separate or the same route for upload/delete. Depending on your situation and requirements from the front-end/UX/business teams.

Get that file in API: you mean download the physical file? There shouldn't be a route for that, it's an image/doc file so you can get it with the direct URL, no? Or, if you want to hide that file under some security check, I have this old article: Laravel: Upload File and Hide Real URL for Secure Download under UUID

avatar
You can use Markdown
avatar
You can use Markdown