Klasse ImageController
java.lang.Object
com.spaghetticodegang.trylater.image.ImageController
REST controller providing endpoints for managing image handling.
This controller exposes API endpoints for uploading, uploading with scaling,
and deleting images. All requests are mapped under the "/api/images" base path.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungorg.springframework.http.ResponseEntity
<Void> deleteImage
(String id) Handles the deletion of an image based on its unique ID.org.springframework.http.ResponseEntity
<ImageUploadResponseDto> uploadImage
(@Valid ImageUploadRequestDto request) Handles the upload of a single image file.
-
Konstruktordetails
-
ImageController
public ImageController()
-
-
Methodendetails
-
uploadImage
@PostMapping public org.springframework.http.ResponseEntity<ImageUploadResponseDto> uploadImage(@Valid @ModelAttribute @Valid ImageUploadRequestDto request) Handles the upload of a single image file. This endpoint accepts a multipart file named "image" and delegates the processing to theImageService.uploadImage(MultipartFile)
method. Upon successful upload, it returns aResponseEntity
with anImageUploadResponseDto
in the body and an HTTP status code 201 (CREATED).- Parameter:
request
- TheImageUploadRequestDto
containing the image to be uploaded. This parameter is required and must be named "imageFile" in the request.- Gibt zurück:
- A
ResponseEntity
containing anImageUploadResponseDto
with the ID and path of the uploaded image and an HTTP status code 201 (CREATED).
-
deleteImage
@DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> deleteImage(@PathVariable("id") String id) Handles the deletion of an image based on its unique ID. This endpoint accepts the image ID as a query parameter named "imgPath" and delegates the deletion process to theImageService.deleteImageByImgPath(String)
method. If the image is successfully deleted, it returns aResponseEntity
with an HTTP status code 204 (NO_CONTENT). If the image with the given ID is not found, it returns aResponseEntity
with an HTTP status code 404 (NOT_FOUND).- Parameter:
id
- The unique identifier of the image to be deleted, provided as a query parameter named "imgPath". Must not benull
or empty.- Gibt zurück:
- A
ResponseEntity
with HTTP status code 204 (NO_CONTENT) if the image was successfully deleted, or 404 (NOT_FOUND) if the image with the given ID does not exist.
-