-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b3f736
commit 0390f6a
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...github/msafriends/serviceproduct/moduleapi/controller/internal/v1/AmazonS3Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.msafriends.serviceproduct.moduleapi.controller.internal.v1; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
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.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import com.github.msafriends.serviceproduct.moduleapi.service.productimage.AwsS3Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/internal/v1/s3") | ||
public class AmazonS3Controller { | ||
private final AwsS3Service awsS3Service; | ||
|
||
@PostMapping("/products/{productId}/images") | ||
public ResponseEntity<List<String>> uploadFiles( | ||
@RequestPart List<MultipartFile> multipartFiles, | ||
@PathVariable Long productId | ||
){ | ||
return ResponseEntity.ok(awsS3Service.uploadFile(multipartFiles, productId)); | ||
} | ||
|
||
@DeleteMapping("/products/{imageId}/images") | ||
public ResponseEntity<Void> deleteFile( | ||
@RequestParam String fileName, | ||
@PathVariable(value = "imageId") Long productImageId | ||
){ | ||
awsS3Service.deleteFile(fileName, productImageId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |