Skip to content

Commit

Permalink
#18 - Feat: Add File Upload controller
Browse files Browse the repository at this point in the history
  • Loading branch information
eun61n00 committed Aug 14, 2023
1 parent f254b04 commit 8ab2369
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.routemaster.api.total.domain.file.controller;

import lombok.RequiredArgsConstructor;
import org.routemaster.api.total.domain.file.service.impl.FileUploadService;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.codec.multipart.FilePart;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/file")
@RequiredArgsConstructor
public class FileUploadController {

private final FileUploadService fileUploadService;

@PostMapping(value="/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> upload(@RequestPart("file") FilePart file) throws IOException {
String url = fileUploadService.uploadFileToGCS(file);
return new ResponseEntity<>(url, HttpStatus.OK);
}

}

0 comments on commit 8ab2369

Please sign in to comment.