yeg
2026-09-17 e3f412c5474311a471345ea508db4875c9ec648e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.talentcard.server.upload;
 
import java.util.Map;
 
import com.talentcard.server.common.ApiResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
@RestController
@RequestMapping("/api/merchant/uploads")
public class MerchantUploadController {
    private final ImageUploadService imageUploadService;
 
    public MerchantUploadController(ImageUploadService imageUploadService) {
        this.imageUploadService = imageUploadService;
    }
 
    @PostMapping("/images")
    @ResponseStatus(HttpStatus.CREATED)
    public ApiResponse<Map<String, String>> uploadImage(@RequestParam("file") MultipartFile file) {
        String url = imageUploadService.upload(file).url();
        return ApiResponse.success(Map.of("fileId", url, "url", url));
    }
}