Skip to content

Monerh A#5

Open
Miuroro wants to merge 6 commits into
HackYourAssignment:mainfrom
Miuroro:main
Open

Monerh A#5
Miuroro wants to merge 6 commits into
HackYourAssignment:mainfrom
Miuroro:main

Conversation

@Miuroro

@Miuroro Miuroro commented Jul 2, 2026

Copy link
Copy Markdown

Description

I have finished all three tasks for this assignment. The app runs smoothly, the endpoints work in Postman.

Changes

📝 Task 1: Setup

  • Connected the Spring Boot app to my local PostgreSQL database.
  • Added the Amazon S3 SDK dependency to my pom.xml file.

🎨 Task 2: JSONB and Product Queries

  • Added the details field to the Product code so it shows up in requests.
  • Fixed the query to filter products by color.
  • Implemented the endpoint to update product sizes in the database.

📁 Task 3: Image Upload & Delete

  • Created FileService to handle uploading and deleting images.
  • Configured the S3 client to run with anonymous access so it doesn't crash on startup or trigger SonarQube errors (S6242).
  • Fixed the ProductController to accept file uploads properly.
  • Tested everything in Postman (uploading an image saves the URL to the DB, and deleting it sets it back to null).

Everything compiles and runs perfectly.

I fixed the PR issue by rebasing onto the correct repository. The code is all ready for review now!

@@ -26,14 +27,18 @@ public ProductResponse setProductSize(int id, String size) {
}

public ProductResponse setProductImage(int id, MultipartFile file) {

@dilero dilero Jul 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what happens if the file is null? No exception handling exist in this method.

new TypeReference<Map<String, Object>>() {}));
}
} catch (Exception e) {
throw new RuntimeException(e);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logging the error would be helpful here

logger.warning("Bucket connection skipped: " + e.getMessage());
}

return "https://s3.eu-central-003.backblazeb2.com/file/" + bucket + "/" + key;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Extracting that URL into a constant (e.g. BASE_STORAGE_URL) helps because:

Single source of truth — if the bucket or region changes, you update one place, not hunt through 15 files
Readability — BASE_STORAGE_URL + path is clearer than a raw URL blob
Typo prevention — one misspelled character in a pasted URL is hard to spot; a misspelled constant name throws an error immediately

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.

3 participants