| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.minio.MinioClient; |
| | | import io.minio.errors.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | |
| | | import org.springblade.core.oss.model.BladeFile; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.jfpt.alarm.service.IAlarmService; |
| | | import org.springblade.jfpt.avideo.entity.Avideo; |
| | | import org.springblade.jfpt.avideo.service.IAvideoService; |
| | | import org.springblade.jfpt.wj.entity.Wj; |
| | | import org.springblade.jfpt.wj.service.IWjService; |
| | | import org.springblade.jfpt.xlfeedback.entity.Xlfeedback; |
| | |
| | | import org.springblade.jfpt.xlfeedback.wrapper.XlfeedbackWrapper; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.xmlpull.v1.XmlPullParserException; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | private final IXlfeedbackService xlfeedbackService; |
| | | private IWjService iWjService; |
| | | private MinioTemplate minioTemplate; |
| | | private final IAlarmService alarmService; |
| | | private final IAvideoService iAvideoService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | return R.data(link); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param file |
| | | */ |
| | | @PostMapping("put-objects") |
| | | public R put(@RequestParam MultipartFile file) throws InvalidPortException, InvalidEndpointException, IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException, InternalException, NoResponseException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, RegionConflictException { |
| | | MinioClient minioClient = new MinioClient("http://36.134.81.48:9000","adminminio","adminminio"); |
| | | if (!minioClient.bucketExists("jfpt")) { //是否存在名为“test”的bucket |
| | | minioClient.makeBucket("jfpt"); |
| | | } |
| | | String fileName = file.getOriginalFilename(); |
| | | String newName ="upload/"+UUID.randomUUID().toString().replaceAll("-", "") |
| | | + fileName.substring(fileName.lastIndexOf(".")); |
| | | InputStream inputStream = file.getInputStream(); //获取file的inputStream |
| | | minioClient.putObject("jfpt", newName, inputStream, "application/octet-stream");//上传 |
| | | inputStream.close(); |
| | | String url = minioClient.getObjectUrl("jfpt", newName); //文件访问路径 |
| | | return R.data(url); |
| | | } |
| | | |
| | | /** |
| | | * @param file |
| | | */ |
| | | @PostMapping("put-objecty") |
| | | public R puty(@RequestParam MultipartFile file,String jid) throws InvalidPortException, InvalidEndpointException, IOException, XmlPullParserException, NoSuchAlgorithmException, InvalidKeyException, InvalidArgumentException, InternalException, NoResponseException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, RegionConflictException { |
| | | MinioClient minioClient = new MinioClient("http://web.byisf.com:9000","adminminio","adminminio"); |
| | | if (!minioClient.bucketExists("jfpt")) { |
| | | minioClient.makeBucket("jfpt"); |
| | | } |
| | | String fileName = file.getOriginalFilename(); |
| | | String newName ="upload/avoid/"+UUID.randomUUID().toString().replaceAll("-", "") |
| | | + fileName.substring(fileName.lastIndexOf(".")); |
| | | InputStream inputStream = file.getInputStream(); //获取file的inputStream |
| | | minioClient.putObject("jfpt", newName, inputStream, "application/octet-stream");//上传 |
| | | inputStream.close(); |
| | | String url = minioClient.getObjectUrl("jfpt", newName); //文件访问路径 |
| | | String substring = url.substring(25, url.length()); |
| | | String urls="https://web.byisf.com/minio"+substring; |
| | | //alarmService.updateAaddress(urls,jid); |
| | | Avideo avideo = new Avideo(); |
| | | avideo.setJid(jid); |
| | | avideo.setAddress(urls); |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String time = sim.format(dd); |
| | | avideo.setRtime(time); |
| | | iAvideoService.save(avideo); |
| | | return R.data(urls); |
| | | } |
| | | |
| | | } |