Skip to content

Commit

Permalink
new: ImageController for returning images
Browse files Browse the repository at this point in the history
  • Loading branch information
Altair-Bueno committed May 26, 2022
1 parent 83ade1d commit 246a0a0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/uma/taw/ubayspring/controller/ImageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package uma.taw.ubayspring.controller;

import com.jlefebure.spring.boot.minio.MinioException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import uma.taw.ubayspring.wrapper.MinioWrapperService;

import java.io.IOException;

@RequestMapping("/image")
@RestController
public class ImageController {
@Autowired
MinioWrapperService minioWrapperService;

@GetMapping(produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public @ResponseBody byte[] getImage(@RequestParam String id) throws MinioException, IOException {
var stream = minioWrapperService.getObject(id);
return stream.readAllBytes();
}
}

0 comments on commit 246a0a0

Please sign in to comment.