IntelligentRecognition/ah-jjsp-service/.svn/pristine/8c/8c721a1a6722149a19194b110bd...

43 lines
1.2 KiB
Plaintext
Raw Normal View History

2024-05-24 16:09:40 +08:00
package com.securityControl.file.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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;
import com.securityControl.common.core.utils.file.FileTypeUtils;
/**
* FastDFS 文件存储
*
* @author czc
*/
@Service
public class FastDfsSysFileServiceImpl implements ISysFileService
{
/**
* 域名或本机访问地址
*/
@Value("${fdfs.domain}")
public String domain;
@Autowired
private FastFileStorageClient storageClient;
/**
* FastDfs文件上传接口
*
* @param file 上传的文件
* @return 访问地址
* @throws Exception
*/
@Override
public String uploadFile(MultipartFile file) throws Exception
{
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
FileTypeUtils.getExtension(file), null);
return domain + "/" + storePath.getFullPath();
}
}