You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
795 B
26 lines
795 B
package com.example.demo.controller;
|
|
|
|
|
|
|
|
import com.example.demo.Util.UploadUtil;
|
|
import com.example.demo.domain.vo.Result;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
@RestController
|
|
@RequestMapping("/upload")
|
|
@CrossOrigin
|
|
public class UploadController {
|
|
@Value("${upload.path}")
|
|
private String path;
|
|
|
|
@PostMapping
|
|
public Result upload(MultipartFile file) {
|
|
String fileName = UploadUtil.save(file,path);
|
|
return Result.success(fileName);
|
|
}
|
|
}
|