|
|
@ -4,6 +4,7 @@ import com.bnyer.common.core.exception.ServiceException; |
|
|
import com.bnyer.file.config.MinioConfig; |
|
|
import com.bnyer.file.config.MinioConfig; |
|
|
import com.bnyer.file.utils.ImgUtil; |
|
|
import com.bnyer.file.utils.ImgUtil; |
|
|
import io.minio.ObjectStat; |
|
|
import io.minio.ObjectStat; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import net.coobird.thumbnailator.Thumbnails; |
|
|
import net.coobird.thumbnailator.Thumbnails; |
|
|
import org.apache.commons.compress.utils.IOUtils; |
|
|
import org.apache.commons.compress.utils.IOUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -24,6 +25,7 @@ import java.net.URLEncoder; |
|
|
* @author ruoyi |
|
|
* @author ruoyi |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
|
|
|
@Slf4j |
|
|
public class MinioSysFileServiceImpl implements MinioService |
|
|
public class MinioSysFileServiceImpl implements MinioService |
|
|
{ |
|
|
{ |
|
|
@Autowired |
|
|
@Autowired |
|
|
@ -53,6 +55,19 @@ public class MinioSysFileServiceImpl implements MinioService |
|
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; |
|
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String uploadBanner(MultipartFile file) throws Exception { |
|
|
|
|
|
String fileName = FileUploadUtils.extractFilename(file); |
|
|
|
|
|
PutObjectArgs args = PutObjectArgs.builder() |
|
|
|
|
|
.bucket("banner") |
|
|
|
|
|
.object(fileName) |
|
|
|
|
|
.stream(file.getInputStream(), file.getSize(), -1) |
|
|
|
|
|
.contentType(file.getContentType()) |
|
|
|
|
|
.build(); |
|
|
|
|
|
client.putObject(args); |
|
|
|
|
|
return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String uploadFileByThumb(MultipartFile file) throws Exception { |
|
|
public String uploadFileByThumb(MultipartFile file) throws Exception { |
|
|
boolean b = ImgUtil.isPicture(file.getOriginalFilename()); |
|
|
boolean b = ImgUtil.isPicture(file.getOriginalFilename()); |
|
|
@ -86,6 +101,7 @@ public class MinioSysFileServiceImpl implements MinioService |
|
|
IOUtils.copy(is, response.getOutputStream()); |
|
|
IOUtils.copy(is, response.getOutputStream()); |
|
|
is.close(); |
|
|
is.close(); |
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
|
|
|
|
log.error("文件下载失败!原因为:",e); |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|