-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStorageImageController.java
More file actions
32 lines (27 loc) · 1.35 KB
/
StorageImageController.java
File metadata and controls
32 lines (27 loc) · 1.35 KB
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
30
31
32
package dev.steady.storage.controller;
import dev.steady.global.auth.Auth;
import dev.steady.global.auth.UserInfo;
import dev.steady.storage.ImageUploadPurpose;
import dev.steady.storage.service.StorageService;
import dev.steady.user.dto.response.PutObjectUrlResponse;
import lombok.RequiredArgsConstructor;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/storage/image")
public class StorageImageController {
private final StorageService storageService;
@GetMapping("/{purpose}")
public ResponseEntity<PutObjectUrlResponse> getImageUploadUrl(@PathVariable String purpose,
@RequestParam String fileName,
@Auth UserInfo userInfo) {
String keyPattern = ImageUploadPurpose.from(purpose).getKeyPattern();
PutObjectUrlResponse response = storageService.generatePutObjectUrl(fileName, keyPattern);
return ResponseEntity.ok(response);
}
}