package com.wzy.oss.controller;
import com.wzy.commonutils.R;
import com.wzy.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
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(value = "/eduoss/fileoss")
@CrossOrigin//跨域
public class OssController {
@Autowired
private OssService ossService;
/*
* @description 长传头像功能
* @author WangZiyao
* @date 2021/9/20 0020 15:35
* @param [org.springframework.web.multipart.support.MultipartFilter]
* @return com.wzy.commonutils.R
*/
@PostMapping(value = "/uploadOssFile")
public R uploadOssFile(MultipartFile file) {
//MultipartFilter:获取上传文件,它是固定的类型。
//上传头像,并返回上传到oss的头像的路径
String url = ossService.uploadFileAvatar(file);
return R.ok().data("url",url);
}
}