52 lines
1.6 KiB
Java
52 lines
1.6 KiB
Java
package com.mattrixwv.raidbuilder.controller;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import com.mattrixwv.raidbuilder.annotation.AccountAuthorization;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping("/icons")
|
|
public class IconController{
|
|
@Value("${uploadFileDirectory}")
|
|
private String uploadFileDirectory;
|
|
|
|
|
|
@GetMapping("/gameIcons/{gameIconName}")
|
|
@AccountAuthorization(permissions = {})
|
|
public ResponseEntity<byte[]> getGameIcons(@PathVariable("gameIconName") String gameIconName) throws IOException{
|
|
log.info("Getting game icon {}", gameIconName);
|
|
|
|
|
|
byte[] resource = Files.readAllBytes(Path.of(uploadFileDirectory + "/gameIcons/" + gameIconName));
|
|
|
|
|
|
return ResponseEntity.ok().body(resource);
|
|
}
|
|
|
|
@GetMapping("/raidGroupIcons/{raidGroupIconName}")
|
|
@AccountAuthorization(permissions = {})
|
|
public ResponseEntity<byte[]> getRaidGroupIcons(@PathVariable("raidGroupIconName") String raidGroupIconName) throws IOException{
|
|
log.info("Getting raid group icon {}", raidGroupIconName);
|
|
|
|
|
|
byte[] resource = Files.readAllBytes(Path.of(uploadFileDirectory + "/raidGroupIcons/" + raidGroupIconName));
|
|
|
|
|
|
return ResponseEntity.ok().body(resource);
|
|
}
|
|
}
|