diff --git a/src/main/java/uma/taw/ubayspring/controller/ImageController.java b/src/main/java/uma/taw/ubayspring/controller/ImageController.java new file mode 100644 index 0000000..c208af4 --- /dev/null +++ b/src/main/java/uma/taw/ubayspring/controller/ImageController.java @@ -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(); + } +}