FileController.java 763 Bytes
Newer Older
张辰's avatar
张辰 committed
1 2 3
package com.tanpu.community.controller;

import com.tanpu.common.api.CommonResp;
刘基明's avatar
刘基明 committed
4
import com.tanpu.community.api.beans.resp.FileUploadResp;
张辰's avatar
张辰 committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import com.tanpu.community.manager.FileManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Slf4j
@RequestMapping(value = "/api/file")
public class FileController {

    @Autowired
    private FileManager fileManager;

    @PostMapping("/uploadFile")
    @ResponseBody
刘基明's avatar
刘基明 committed
21
    public CommonResp<FileUploadResp> uploadToRemote(@RequestParam(value = "file") MultipartFile file) {
张辰's avatar
张辰 committed
22 23 24
        return CommonResp.success(fileManager.uploadFile(file));
    }
}