Buenas prácticas a nivel general
Convenciones para crear APIs: rutas y datos
¿Qué son los HTTP Status Codes?
¿Qué son los Métodos HTTP?
Creación del proyecto
Boilerplate y estructura de datos en frameworks de backend
Creación de datos: factories y seeders
Consulta de datos: rutas y controladores
Consulta de datos con tablas relacionadas
Quiz: Creación del proyecto
Planificación y mantenimiento
¿Cómo planificar el alcance de tus APIs?
Consistencia entre endpoints: recursos y colecciones
Recursos anidados o multinivel
Optimización y auditoría de APIs
Alteración de datos
Validación de datos
Quiz: Planificación y mantenimiento
Funciones de seguridad
Autenticación vs. autorización
Autorización: tokens y middlewares
Autenticación: inicio de sesión y generación de tokens
Corrigiendo bugs de seguridad
Políticas de acceso
Subir imágenes desde API
¿Qué es la autenticación?
Quiz: Funciones de seguridad
API Testing
API Testing
Testing en tags
Testing en recipes
Testing método store
Testing método update
Quiz: API Testing
API Breaking Changes
Versionamiento de la API
Evolución de la API: v2, paginación y TDD
Quiz: API Breaking Changes
Conclusiones
Recapitulación de las buenas prácticas para desarrollo de APIs
Comparte tus buenas prácticas con la comunidad
You don't have access to this class
Keep learning! Join and start boosting your career
Adding the ability to upload images to your administration system not only improves functionality, but can also enhance the user experience. Today, we will learn how to implement this process using Laravel and Visual Studio Code. Join us on this technical journey!
The first step is to make sure that the system can validate the images properly. We work on the project controller, specifically where requests (Requests) and connections are managed. Here we are interested in two things:
To handle image validation, in the Laravel validation system, we add the rule that specifies that the image field is mandatory and must be an image file. This is done as follows:
$request->validate([ ' image' => 'required|image|mimes:jpeg,png,jpg',]);
Practice is essential to ensure that our system works correctly. If you are using Postman:
Security is crucial when we allow file uploads. Here are some best practices:
MAX:value
rule.For example, the validation code to limit the size may look like this:
$request->validate([ ' image' => 'required|image|mimes:jpeg,png,jpg|max:2048', // 2MB]);
To update records and images, use a conditional to check if the image was sent:
Example code for a conditional update:
if ($request->hasFile('image')) { $image = $request->file('image')->store('public/recipes'); // Update the registry with the new image}
Remember, to test this functionality you must be authenticated. Use an access token and specify the ID of the record you wish to update when making a PUT request.
These steps ensure that you can control the flow of images in your administration system efficiently and securely. Keep practicing and improve your development skills day by day!
Contributions 3
Questions 0
Want to see more contributions, questions and answers from the community?