|
|
|
@ -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();
|
|
|
|
|