Skip to content

Commit

Permalink
Image업로드 API 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
Due-IT committed Jan 5, 2024
1 parent 8fd62cb commit 67ed0f5
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.project.Glog.controller;

import com.project.Glog.util.AwsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
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 java.io.IOException;

@RestController
public class ImageController {
@Autowired
private AwsUtils awsUtils;
@PostMapping("/image")
public ResponseEntity<String> uploadImage(@RequestPart(value="image", required = true) MultipartFile multipartFile) throws IOException {
String path = awsUtils.upload(multipartFile, "postImage").getPath();
return new ResponseEntity<>(path, HttpStatus.OK);
}
}

0 comments on commit 67ed0f5

Please sign in to comment.