update ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/service/FastDfsSysFileServiceImpl.java.

pull/70/head
Mood 4 years ago committed by Gitee
parent 23944b2f9c
commit 2bb479ef28

@ -1,42 +1,43 @@
package com.ruoyi.file.service; package com.ruoyi.file.service;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.multipart.MultipartFile; import org.springframework.stereotype.Service;
import com.github.tobato.fastdfs.domain.fdfs.StorePath; import org.springframework.web.multipart.MultipartFile;
import com.github.tobato.fastdfs.service.FastFileStorageClient; import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
/**
* FastDFS /**
* * FastDFS
* @author ruoyi *
*/ * @author ruoyi
@Service */
public class FastDfsSysFileServiceImpl implements ISysFileService @Service
{ public class FastDfsSysFileServiceImpl implements ISysFileService
/** {
* 访 /**
*/ * 访
@Value("${fdfs.domain}") */
public String domain; @Value("${fdfs.domain}")
public String domain;
@Autowired
private FastFileStorageClient storageClient; @Autowired
private FastFileStorageClient storageClient;
/**
* FastDfs /**
* * FastDfs
* @param file *
* @return 访 * @param file
* @throws Exception * @return 访
*/ * @throws Exception
@Override */
public String uploadFile(MultipartFile file) throws Exception @Override
{ public String uploadFile(MultipartFile file) throws Exception
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(), {
FilenameUtils.getExtension(file.getOriginalFilename()), null); StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
return domain + "/" + storePath.getFullPath(); FileUploadUtils.getExtension(file), null);
} return domain + "/" + storePath.getFullPath();
} }
}

Loading…
Cancel
Save