Skip to content

Feat: Upload profile image#693

Merged
phoenixdahdev merged 4 commits intohngprojects:devfrom
nevisadhiambo:feat-profile-image
Mar 2, 2025
Merged

Feat: Upload profile image#693
phoenixdahdev merged 4 commits intohngprojects:devfrom
nevisadhiambo:feat-profile-image

Conversation

@nevisadhiambo
Copy link
Contributor

@nevisadhiambo nevisadhiambo commented Feb 28, 2025

Upload Profile Image API Implementation

Fix: Implemented required changes for issue #677

Description

This PR addresses issue #677 by implementing a new endpoint for uploading profile images. The image is stored in memory, and a correlating link is provided for access. The following modifications were made:

[Changes]

  • Implemented a new endpoint for uploading profile images.
  • Replaced in-memory storage with direct S3 upload.
  • Configured AWS S3 properties in the properties file
  • Updated file handling to use InputStream instead of File for better efficiency.
  • Provided a generated S3 URL for accessing stored images.

successful and failure Test Screenshots

32Fqi12.md.png
32Fnv5P.md.png
32Fx0N9.png

Testing Instructions

  1. Clone the repository and checkout this branch.
  2. Run the application using mvn spring-boot:run.
  3. Use a tool like Postman or Curl to send requests to the new endpoint:
  curl --location --request POST 'http://localhost:8080/api/v1/profile/upload-image' \
  --header 'Content-Type: multipart/form-data' \
  --header 'Authorization: Bearer jwttoken' \
  --form 'image=@"/path/to/your/image.jpg"'  
  1. Verify that the response matches the expected output

Checklist

  • My code follows the project’s coding style.
  • I have tested my changes locally.

Related Issues

Closes #677

@nevisadhiambo nevisadhiambo changed the title Feat profile image Feat: Upload profile image Feb 28, 2025
Copy link
Contributor

@Am0du Am0du left a comment

Choose a reason for hiding this comment

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

Configure to use s3 bucket and add the necessary configs to application-example.properties


@Service
@RequiredArgsConstructor
//@RequiredArgsConstructor
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have reverted back to the original code basee structured


private static final String UPLOAD_DIR = "profile_photos";

public ProfileServiceImpl(UserService userService, UserRepository userRepository, ProfileRepository profileRepository) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Codebase is designed to use lombok for constructor injection

@nevisadhiambo
Copy link
Contributor Author

@Am0du I've implemented the profile image upload using AWS S3, updated the configuration, and improved error handling.

@nevisadhiambo nevisadhiambo requested a review from Am0du March 1, 2025 11:14
@nevisadhiambo
Copy link
Contributor Author

updated success response

aws

@nevisadhiambo
Copy link
Contributor Author

new location of file saved

bucket

@phoenixdahdev phoenixdahdev merged commit 526a9dd into hngprojects:dev Mar 2, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT: Implement Upload Profile Image Endpoint

3 participants