文件上传 moni
This commit is contained in:
parent
6f8823b373
commit
d0e85a00f8
|
|
@ -1,12 +1,13 @@
|
|||
package com.ruoyi.file.service;
|
||||
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
|
||||
/**
|
||||
* FastDFS 文件存储
|
||||
|
|
@ -14,8 +15,8 @@ import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||
{
|
||||
@ConfigurationProperties(prefix = "fdfs")
|
||||
public class FastDfsSysFileServiceImpl implements ISysFileService {
|
||||
/**
|
||||
* 域名或本机访问地址
|
||||
*/
|
||||
|
|
@ -33,8 +34,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
|
|||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
public String uploadFile(MultipartFile file) throws Exception {
|
||||
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
|
||||
FilenameUtils.getExtension(file.getOriginalFilename()), null);
|
||||
return domain + "/" + storePath.getFullPath();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.file.utils.FileUploadUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 本地文件存储
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Primary
|
||||
@Service
|
||||
public class LocalSysFileServiceImpl implements ISysFileService
|
||||
{
|
||||
|
||||
//@Service
|
||||
//@ConfigurationProperties(prefix = "fdfs")
|
||||
public class LocalSysFileServiceImpl implements ISysFileService {
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
|
|
@ -40,8 +38,8 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
|||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws Exception {
|
||||
String name = FileUploadUtils.upload(localFilePath, file);
|
||||
String url = domain + localFilePrefix + name;
|
||||
return url;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package com.ruoyi.file.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.file.config.MinioConfig;
|
||||
import com.ruoyi.file.utils.FileUploadUtils;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectArgs;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* Minio 文件存储
|
||||
|
|
@ -14,8 +15,8 @@ import io.minio.PutObjectArgs;
|
|||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class MinioSysFileServiceImpl implements ISysFileService
|
||||
{
|
||||
@Primary
|
||||
public class MinioSysFileServiceImpl implements ISysFileService {
|
||||
@Autowired
|
||||
private MinioConfig minioConfig;
|
||||
|
||||
|
|
@ -29,8 +30,8 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
|||
* @return 访问地址
|
||||
* @throws Exception
|
||||
*/
|
||||
public String uploadFile(MultipartFile file) throws Exception
|
||||
{
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws Exception {
|
||||
String fileName = FileUploadUtils.extractFilename(file);
|
||||
PutObjectArgs args = PutObjectArgs.builder()
|
||||
.bucket(minioConfig.getBucketName())
|
||||
|
|
|
|||
Loading…
Reference in New Issue