Merge branch 'dev'
This commit is contained in:
@@ -6,6 +6,7 @@ import com.sb.web.board.domain.BoardImage;
|
||||
import com.sb.web.board.service.BoardImageService;
|
||||
import com.sb.web.common.exception.ApiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.CacheControl;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -28,6 +29,10 @@ public class BoardImageController {
|
||||
|
||||
private final BoardImageService service;
|
||||
|
||||
// 앱(Capacitor) 출처가 localhost 라 상대경로가 안 통하므로 절대 URL 로 반환
|
||||
@Value("${app.public-url:}")
|
||||
private String publicUrl;
|
||||
|
||||
@PostMapping("/api/board/images")
|
||||
public Map<String, String> upload(
|
||||
@RequestParam("image") MultipartFile file,
|
||||
@@ -40,7 +45,8 @@ public class BoardImageController {
|
||||
throw new ApiException(HttpStatus.BAD_REQUEST, "이미지 파일만 업로드할 수 있습니다.");
|
||||
}
|
||||
Long id = service.save(current.getId(), contentType, file.getBytes());
|
||||
return Map.of("url", "/api/images/" + id);
|
||||
String base = (publicUrl == null) ? "" : publicUrl.replaceAll("/+$", "");
|
||||
return Map.of("url", base + "/api/images/" + id);
|
||||
}
|
||||
|
||||
@GetMapping("/api/images/{id}")
|
||||
|
||||
@@ -74,6 +74,8 @@ google:
|
||||
app:
|
||||
crypto:
|
||||
account-key: ${ACCOUNT_CRYPTO_KEY:}
|
||||
# 업로드 이미지 등 외부에서 접근할 절대 URL 베이스. 앱(Capacitor)은 출처가 localhost 라 상대경로가 안 통함.
|
||||
public-url: ${PUBLIC_URL:https://app.sblog.kr}
|
||||
|
||||
# ===== Logging =====
|
||||
logging:
|
||||
|
||||
Reference in New Issue
Block a user