added advertising
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.krylov.refound.controller.advertising;
|
||||
|
||||
import com.krylov.refound.service.advertising.AdvertisingMediaService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Публичный прокси-эндпоинт медиа рекламы. Ключи объектов содержат слэши
|
||||
* (например "images/<uuid>.jpg"), поэтому используем wildcard {*key},
|
||||
* как в FileStorageController для картинок постов.
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/ads-media")
|
||||
@RequiredArgsConstructor
|
||||
public class AdvertisingMediaController {
|
||||
|
||||
private final AdvertisingMediaService mediaService;
|
||||
|
||||
@GetMapping("/{*key}")
|
||||
public ResponseEntity<byte[]> getMedia(@PathVariable String key) {
|
||||
String mediaKey = key.startsWith("/") ? key.substring(1) : key;
|
||||
log.info("GET ads-media: key={} -> mediaKey={}", key, mediaKey);
|
||||
return mediaService.downloadMedia(mediaKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user