| | |
| | | import com.ruoyi.basic.pojo.WorkShop; |
| | | import com.ruoyi.basic.pojo.WorkShopFile; |
| | | import com.ruoyi.basic.service.WorkShopService; |
| | | import com.ruoyi.common.config.MinioConfig; |
| | | import com.ruoyi.common.core.domain.MinioResult; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.file.MinioUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | @Resource |
| | | private MinioUtils minioUtils; |
| | | |
| | | @Value("${minio.bucketName}") |
| | | private String bucketName; |
| | | @Autowired |
| | | private MinioConfig minioConfig; |
| | | |
| | | |
| | | @Override |
| | |
| | | try { |
| | | String contentType = file.getContentType(); |
| | | String category = contentType != null && contentType.startsWith("image/") ? "images" : "docs"; |
| | | MinioResult upload = minioUtils.upload(bucketName, file, true); |
| | | MinioResult upload = minioUtils.upload(minioConfig.getBucketName(), file, true); |
| | | // 记录存储路径 |
| | | workShopFile.setFileUrl(upload.getBucketFileName()); |
| | | workShopFile.setFileMinioUrl(upload.getPreviewExpiry()); |