This commit is contained in:
@@ -15,6 +15,7 @@ import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -173,4 +174,21 @@ public class UserController {
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Operation(summary = "Get the profile Picture of the user.", description = "A user can get their displayed profile picture.")
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(responseCode = "200", description = "Profile picture successfully retrieved",
|
||||
content = @Content(mediaType = "image/jpeg")),
|
||||
@ApiResponse(responseCode = "304", description = "Profile picture not modified since last request"),
|
||||
@ApiResponse(responseCode = "403", description = "Only authorized persons may see the profiles picture"),
|
||||
@ApiResponse(responseCode = "404", description = "The user does not exist")
|
||||
})
|
||||
@GetMapping("/getProfilePicture/{id}")
|
||||
public ResponseEntity<byte[]> getProfilePicture(@PathVariable @NotNull Long id) {
|
||||
byte[] imageData = userService.getProfilePicture(id);
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(MediaType.IMAGE_JPEG)
|
||||
.cacheControl(CacheControl.maxAge(365, TimeUnit.DAYS))
|
||||
.body(imageData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user