Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added upload_image admin route for image uploads #370

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

salazarsebas
Copy link
Contributor


fix: Add upload_image admin route for uploading images

Description

This pull request addresses **Issue #360 **, implementing an admin route that allows users to upload images.

Changes Made

  • Created a new file: src/endpoints/admin/upload_image.rs.
  • Implemented the upload_image_handler function, which:
    • Accepts multipart form data for uploading an image.
    • Saves the image to the ./images folder with the specified image_name and .webp extension.
    • Ensures only .webp files are allowed.
    • Creates the ./images folder if it doesn’t exist.

Checklist

  • Route works as expected for valid .webp images.
  • Non-.webp files return an appropriate error response.
  • Code reviewed for best practices and error handling.

Issue Reference

Close #360


Evidence

upload_image.rs
code_of_upload_image

mod.rs
add_to_mod


Additional Notes

  • Please review and suggest any improvements or additional test cases.
  • Thank you for your time and feedback!

@salazarsebas
Copy link
Contributor Author

Hi @fricoben and @Marchand-Nicolas here is my pull request, please tell me what you think, I am open to any comments. Good day. 🫡🚀

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't build, there are a lot of compilations errors. Please test your code (cargo run)

@Marchand-Nicolas Marchand-Nicolas added the ❌ Change request Change requested from reviewer label Jan 23, 2025
@salazarsebas
Copy link
Contributor Author

It doesn't build, there are a lot of compilations errors. Please test your code (cargo run)

Hi, an apology for that error, my versions are not working properly, I will fix it as soon as possible.

@salazarsebas
Copy link
Contributor Author

Sorry again. Here is running fine cargo build, it has some warnings that are from other files. Thanks for your patience.

Screenshot 2025-01-24 at 1 53 01 AM Screenshot 2025-01-24 at 1 53 16 AM Screenshot 2025-01-24 at 1 53 27 AM Screenshot 2025-01-24 at 1 53 40 AM Screenshot 2025-01-24 at 1 53 55 AM Screenshot 2025-01-24 at 1 54 05 AM Screenshot 2025-01-24 at 1 54 17 AM Screenshot 2025-01-24 at 1 54 29 AM Screenshot 2025-01-24 at 1 54 39 AM Screenshot 2025-01-24 at 1 54 47 AM Screenshot 2025-01-24 at 1 55 02 AM

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@Marchand-Nicolas Marchand-Nicolas merged commit 00b0897 into lfglabs-dev:testnet Jan 24, 2025
@salazarsebas
Copy link
Contributor Author

Thank you very much for the opportunity to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌ Change request Change requested from reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New upload image route
2 participants