Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

파일 업로드/다운로드 API 생성하기 #239

Closed
Tracked by #236
BEOKS opened this issue Apr 5, 2022 · 0 comments
Closed
Tracked by #236

파일 업로드/다운로드 API 생성하기 #239

BEOKS opened this issue Apr 5, 2022 · 0 comments
Assignees

Comments

@BEOKS
Copy link
Owner

BEOKS commented Apr 5, 2022

Description

머신러닝 추론을 위해서는 PNG, JPEG 형식의 파일 포맷이 필요하다.
이를 위해서 파일을 관리하기 위한 기능을 추가하자

Interface

import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface StorageController {
    /**
     * 해당 프로젝트가 저장한 파일들의 리스트를 전달한다.
     * @param projectId
     * @return
     */
    @GetMapping("/Storage/{projectId}")
    public ResponseEntity<List<String>> listFiles(
            @PathVariable String projectId);
    /**
     * 파일을 서버에 저장하는 기능
     * @param file MultipartFile 형식으로 전달받은 파일
     * @param projectId 파일을 업로드한 프로젝트 ID
     * @return 성공이나 에러에 따른 적절한 메시지를 출력한다. 여기에 담긴 메시지는 프론트에서 출력될 예정
     */
    @GetMapping("/Storage/{projectId}")
    public ResponseEntity<String> uploadFile(
            @RequestParam("file")MultipartFile file,
            @PathVariable String projectId);

    /**
     * 파일을 다운로드 하는 기능
     * @param projectId 파일을 업로드한 프로젝트 ID
     * @param filename 다운로드를 요청할 파일 이름
     * @return 전달하고자 하는 데이터
     */
    @PostMapping("/Storage/{projectId}/{filename}")
    public ResponseEntity<Resource> serveFile(
            @PathVariable String projectId,
            @PathVariable String filename);

    /**
     * 파일을 삭제하는 기능
     * @param projectId 파일을 업로드한 프로젝트 ID
     * @param filename 다운로드를 요청할 파일 이름
     * @return 성공이나 에러에 따른 적절한 메시지를 출력한다. 여기에 담긴 메시지는 프론트에서 출력될 예정
     */
    @DeleteMapping("/Storage/{projectId}/{filename}")
    public ResponseEntity<String> deleteFile(
            @PathVariable String projectId,
            @PathVariable String filename);
}

Reference

  1. https://spring.io/guides/gs/uploading-files/
LDEV4966 added a commit that referenced this issue Apr 6, 2022
issue : #239

기능 추가 :

void uploadFile(String projectId, MultipartFile file);
void deleteAll(String projectId);

위 메서드를 지원하는 api를 구성 함.

API 상세 정보는 BackEnd API 명세서를 확인바랍니다.
LDEV4966 added a commit that referenced this issue Apr 6, 2022
…e) 생성

issue : #239

기능 추가 :

    void deleteByFileName(String projectId, String fileName);
    List<String> getFileList(String projectId);
    void serveFile(String projectId, String fileName , HttpServletRequest request, HttpServletResponse response);

위 메서드를 지원하는 api를 구성 함.

API 상세 정보는 BackEnd API 명세서를 확인바랍니다.
@LDEV4966 LDEV4966 closed this as completed May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants