文件上传 moni

pull/64/head
陈云志 5 years ago
parent 6f8823b373
commit d0e85a00f8

@ -1,21 +1,22 @@
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
*
*
* @author ruoyi
*/
@Service
public class FastDfsSysFileServiceImpl implements ISysFileService
{
@ConfigurationProperties(prefix = "fdfs")
public class FastDfsSysFileServiceImpl implements ISysFileService {
/**
* 访
*/
@ -27,14 +28,13 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
/**
* FastDfs
*
*
* @param file
* @return 访
* @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 com.ruoyi.file.utils.FileUploadUtils;
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;
/**
*
*
*
* @author ruoyi
*/
@Primary
@Service
public class LocalSysFileServiceImpl implements ISysFileService
{
//@Service
//@ConfigurationProperties(prefix = "fdfs")
public class LocalSysFileServiceImpl implements ISysFileService {
/**
*
*/
@ -26,7 +24,7 @@ public class LocalSysFileServiceImpl implements ISysFileService
*/
@Value("${file.domain}")
public String domain;
/**
*
*/
@ -35,13 +33,13 @@ public class LocalSysFileServiceImpl implements ISysFileService
/**
*
*
*
* @param file
* @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,21 +1,22 @@
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
*
*
* @author ruoyi
*/
@Service
public class MinioSysFileServiceImpl implements ISysFileService
{
@Primary
public class MinioSysFileServiceImpl implements ISysFileService {
@Autowired
private MinioConfig minioConfig;
@ -24,13 +25,13 @@ public class MinioSysFileServiceImpl implements ISysFileService
/**
*
*
*
* @param file
* @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…
Cancel
Save