FastDfsSysFileServiceImpl.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.boman.file.service;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.boman.domain.dto.ImportExcelDto;
  4. import org.apache.commons.io.FilenameUtils;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.stereotype.Service;
  8. import org.springframework.web.multipart.MultipartFile;
  9. import com.github.tobato.fastdfs.domain.fdfs.StorePath;
  10. import com.github.tobato.fastdfs.service.FastFileStorageClient;
  11. import java.io.IOException;
  12. import java.util.List;
  13. /**
  14. * FastDFS 文件存储
  15. *
  16. * @author ruoyi
  17. */
  18. @Service
  19. public class FastDfsSysFileServiceImpl implements ISysFileService
  20. {
  21. /**
  22. * 域名或本机访问地址
  23. */
  24. @Value("${fdfs.domain}")
  25. public String domain;
  26. @Autowired
  27. private FastFileStorageClient storageClient;
  28. /**
  29. * FastDfs文件上传接口
  30. *
  31. * @param file 上传的文件
  32. * @return 访问地址
  33. * @throws Exception
  34. */
  35. @Override
  36. public String uploadFile(MultipartFile file) throws Exception
  37. {
  38. StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
  39. FilenameUtils.getExtension(file.getOriginalFilename()), null);
  40. return domain + "/" + storePath.getFullPath();
  41. }
  42. /**
  43. * 功能描述: 上传base64
  44. *
  45. * @param base64 base64
  46. * @return java.lang.String
  47. */
  48. @Override
  49. public String uploadFileBase64(String base64) throws IOException {
  50. return null;
  51. }
  52. /**
  53. * 功能描述: 通用的导入接口
  54. *
  55. * @param multipartFile multipartFile
  56. * @param tableName tableName
  57. * @return java.util.List<com.alibaba.fastjson.JSONObject>
  58. */
  59. @Override
  60. public List<JSONObject> importExcelCommon(ImportExcelDto dto) {
  61. return null;
  62. }
  63. /**
  64. * 功能描述: 通用的导入接口
  65. *
  66. * @param multipartFile multipartFile
  67. * @param tableName tableName
  68. * @return java.util.List<com.alibaba.fastjson.JSONObject>
  69. */
  70. @Override
  71. public List<JSONObject> importExcelCommon(MultipartFile multipartFile, String tableName) throws Exception {
  72. return null;
  73. }
  74. }