| | |
| | | package com.ycl.controller; |
| | | |
| | | import com.ycl.api.CommonResult; |
| | | import com.ycl.dto.media.Media; |
| | | import com.ycl.dto.media.PictureZoomParameter; |
| | | import com.ycl.service.oss.OssService; |
| | | import com.ycl.utils.AliyunUtils; |
| | | import com.ycl.utils.MediaFileUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | 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; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | | @RestController |
| | | @Api(tags = "文件上传") |
| | |
| | | private OssService ossService; |
| | | |
| | | @ApiOperation(value = "上传图片") |
| | | @PostMapping("/upload") |
| | | @PostMapping("/medias") |
| | | public CommonResult<String> uploadImages(MultipartFile file) { |
| | | String url = ossService.uploadImages(file); |
| | | // String url = "https://xshcs.com/img/ercode.7a421889.png?v=1"; |
| | | return CommonResult.success(url, "ok"); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除图片") |
| | | @PostMapping("/delete") |
| | | @PostMapping("media/delete") |
| | | public CommonResult<Boolean> deleteImages(String fileUrl) { |
| | | boolean flag = ossService.deleteImages(fileUrl); |
| | | if (flag) { |
| | |
| | | return CommonResult.failed("fail!"); |
| | | } |
| | | |
| | | @ApiOperation(value = "上传视频") |
| | | @PostMapping("/video") |
| | | public CommonResult<String> uploadVideo(MultipartFile file) { |
| | | String url = ossService.uploadVideo(file); |
| | | return CommonResult.success(url, "ok"); |
| | | } |
| | | |
| | | |
| | | } |