首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

黑马头条(day02)资料

后端 96.75KB 17 需要积分: 1
立即下载

资源介绍:

需要用到的sql脚本,微服务模块,模板文件
package com.heima.file.service.impl; import com.heima.file.config.MinIOConfig; import com.heima.file.config.MinIOConfigProperties; import com.heima.file.service.FileStorageService; import io.minio.GetObjectArgs; import io.minio.MinioClient; import io.minio.PutObjectArgs; import io.minio.RemoveObjectArgs; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Import; import org.springframework.util.StringUtils; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; @Slf4j @EnableConfigurationProperties(MinIOConfigProperties.class) @Import(MinIOConfig.class) public class MinIOFileStorageService implements FileStorageService { @Autowired private MinioClient minioClient; @Autowired private MinIOConfigProperties minIOConfigProperties; private final static String separator = "/"; /** * @param dirPath * @param filename yyyy/mm/dd/file.jpg * @return */ public String builderFilePath(String dirPath,String filename) { StringBuilder stringBuilder = new StringBuilder(50); if(!StringUtils.isEmpty(dirPath)){ stringBuilder.append(dirPath).append(separator); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String todayStr = sdf.format(new Date()); stringBuilder.append(todayStr).append(separator); stringBuilder.append(filename); return stringBuilder.toString(); } /** * 上传图片文件 * @param prefix 文件前缀 * @param filename 文件名 * @param inputStream 文件流 * @return 文件全路径 */ @Override public String uploadImgFile(String prefix, String filename,InputStream inputStream) { String filePath = builderFilePath(prefix, filename); try { PutObjectArgs putObjectArgs = PutObjectArgs.builder() .object(filePath) .contentType("image/jpg") .bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1) .build(); minioClient.putObject(putObjectArgs); StringBuilder urlPath = new StringBuilder(minIOConfigProperties.getReadPath()); urlPath.append(separator+minIOConfigProperties.getBucket()); urlPath.append(separator); urlPath.append(filePath); return urlPath.toString(); }catch (Exception ex){ log.error("minio put file error.",ex); throw new RuntimeException("上传文件失败"); } } /** * 上传html文件 * @param prefix 文件前缀 * @param filename 文件名 * @param inputStream 文件流 * @return 文件全路径 */ @Override public String uploadHtmlFile(String prefix, String filename,InputStream inputStream) { String filePath = builderFilePath(prefix, filename); try { PutObjectArgs putObjectArgs = PutObjectArgs.builder() .object(filePath) .contentType("text/html") .bucket(minIOConfigProperties.getBucket()).stream(inputStream,inputStream.available(),-1) .build(); minioClient.putObject(putObjectArgs); StringBuilder urlPath = new StringBuilder(minIOConfigProperties.getReadPath()); urlPath.append(separator+minIOConfigProperties.getBucket()); urlPath.append(separator); urlPath.append(filePath); return urlPath.toString(); }catch (Exception ex){ log.error("minio put file error.",ex); ex.printStackTrace(); throw new RuntimeException("上传文件失败"); } } /** * 删除文件 * @param pathUrl 文件全路径 */ @Override public void delete(String pathUrl) { String key = pathUrl.replace(minIOConfigProperties.getEndpoint()+"/",""); int index = key.indexOf(separator); String bucket = key.substring(0,index); String filePath = key.substring(index+1); // 删除Objects RemoveObjectArgs removeObjectArgs = RemoveObjectArgs.builder().bucket(bucket).object(filePath).build(); try { minioClient.removeObject(removeObjectArgs); } catch (Exception e) { log.error("minio remove file error. pathUrl:{}",pathUrl); e.printStackTrace(); } } /** * 下载文件 * @param pathUrl 文件全路径 * @return 文件流 * */ @Override public byte[] downLoadFile(String pathUrl) { String key = pathUrl.replace(minIOConfigProperties.getEndpoint()+"/",""); int index = key.indexOf(separator); String bucket = key.substring(0,index); String filePath = key.substring(index+1); InputStream inputStream = null; try { inputStream = minioClient.getObject(GetObjectArgs.builder().bucket(minIOConfigProperties.getBucket()).object(filePath).build()); } catch (Exception e) { log.error("minio down file error. pathUrl:{}",pathUrl); e.printStackTrace(); } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] buff = new byte[100]; int rc = 0; while (true) { try { if (!((rc = inputStream.read(buff, 0, 100)) > 0)) break; } catch (IOException e) { e.printStackTrace(); } byteArrayOutputStream.write(buff, 0, rc); } return byteArrayOutputStream.toByteArray(); } }

资源文件列表:

资料day02.zip 大约有117个文件
  1. 资料day02/
  2. 资料day02/heima-leadnews-article/
  3. 资料day02/heima-leadnews-article/heima-leadnews-article.iml 30.04KB
  4. 资料day02/heima-leadnews-article/pom.xml 1.04KB
  5. 资料day02/heima-leadnews-article/src/
  6. 资料day02/heima-leadnews-article/src/main/
  7. 资料day02/heima-leadnews-article/src/main/java/
  8. 资料day02/heima-leadnews-article/src/main/java/com/
  9. 资料day02/heima-leadnews-article/src/main/java/com/heima/
  10. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/
  11. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/ArticleApplication.java 1.04KB
  12. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/config/
  13. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/controller/
  14. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/controller/v1/
  15. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/controller/v1/ArticleHomeController.java 1.26KB
  16. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/mapper/
  17. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/mapper/ApArticleContentMapper.java 290B
  18. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/mapper/ApArticleMapper.java 501B
  19. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/service/
  20. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/service/ApArticleService.java 569B
  21. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/service/impl/
  22. 资料day02/heima-leadnews-article/src/main/java/com/heima/article/service/impl/ApArticleServiceImpl.java 2.25KB
  23. 资料day02/heima-leadnews-article/src/main/resources/
  24. 资料day02/heima-leadnews-article/src/main/resources/bootstrap.yml 245B
  25. 资料day02/heima-leadnews-article/src/main/resources/logback.xml 2.04KB
  26. 资料day02/heima-leadnews-article/src/main/resources/mapper/
  27. 资料day02/heima-leadnews-article/src/main/resources/mapper/ApArticleMapper.xml 2.26KB
  28. 资料day02/heima-leadnews-article/src/main/resources/templates/
  29. 资料day02/heima-leadnews-article/src/main/resources/templates/article.ftl 8.5KB
  30. 资料day02/heima-leadnews-article/src/test/
  31. 资料day02/heima-leadnews-article/src/test/java/
  32. 资料day02/heima-leadnews-article/src/test/java/com/
  33. 资料day02/heima-leadnews-article/src/test/java/com/heima/
  34. 资料day02/heima-leadnews-article/src/test/java/com/heima/article/
  35. 资料day02/heima-leadnews-article/src/test/java/com/heima/article/test/
  36. 资料day02/heima-leadnews-article/src/test/java/com/heima/article/test/ArticleFreemarkerTest.java 2.59KB
  37. 资料day02/heima-leadnews-article/target/
  38. 资料day02/heima-leadnews-article/target/classes/
  39. 资料day02/heima-leadnews-article/target/classes/bootstrap.yml 245B
  40. 资料day02/heima-leadnews-article/target/classes/com/
  41. 资料day02/heima-leadnews-article/target/classes/com/heima/
  42. 资料day02/heima-leadnews-article/target/classes/com/heima/article/
  43. 资料day02/heima-leadnews-article/target/classes/com/heima/article/ArticleApplication.class 1.64KB
  44. 资料day02/heima-leadnews-article/target/classes/com/heima/article/controller/
  45. 资料day02/heima-leadnews-article/target/classes/com/heima/article/controller/v1/
  46. 资料day02/heima-leadnews-article/target/classes/com/heima/article/controller/v1/ArticleHomeController.class 1.71KB
  47. 资料day02/heima-leadnews-article/target/classes/com/heima/article/mapper/
  48. 资料day02/heima-leadnews-article/target/classes/com/heima/article/mapper/ApArticleContentMapper.class 426B
  49. 资料day02/heima-leadnews-article/target/classes/com/heima/article/mapper/ApArticleMapper.class 809B
  50. 资料day02/heima-leadnews-article/target/classes/com/heima/article/service/
  51. 资料day02/heima-leadnews-article/target/classes/com/heima/article/service/ApArticleService.class 512B
  52. 资料day02/heima-leadnews-article/target/classes/com/heima/article/service/impl/
  53. 资料day02/heima-leadnews-article/target/classes/com/heima/article/service/impl/ApArticleServiceImpl.class 3.05KB
  54. 资料day02/heima-leadnews-article/target/classes/logback.xml 2.04KB
  55. 资料day02/heima-leadnews-article/target/classes/mapper/
  56. 资料day02/heima-leadnews-article/target/classes/mapper/ApArticleMapper.xml 2.26KB
  57. 资料day02/heima-leadnews-article/target/classes/templates/
  58. 资料day02/heima-leadnews-article/target/classes/templates/article.ftl 8.5KB
  59. 资料day02/heima-leadnews-article/target/generated-sources/
  60. 资料day02/heima-leadnews-article/target/generated-sources/annotations/
  61. 资料day02/heima-leadnews-article/target/generated-test-sources/
  62. 资料day02/heima-leadnews-article/target/generated-test-sources/test-annotations/
  63. 资料day02/heima-leadnews-article/target/test-classes/
  64. 资料day02/heima-leadnews-article/target/test-classes/com/
  65. 资料day02/heima-leadnews-article/target/test-classes/com/heima/
  66. 资料day02/heima-leadnews-article/target/test-classes/com/heima/article/
  67. 资料day02/heima-leadnews-article/target/test-classes/com/heima/article/test/
  68. 资料day02/heima-leadnews-article/target/test-classes/com/heima/article/test/ArticleFreemarkerTest.class 5.2KB
  69. 资料day02/heima-leadnews-basic/
  70. 资料day02/heima-leadnews-basic/heima-file-starter/
  71. 资料day02/heima-leadnews-basic/heima-file-starter/heima-file-starter.iml 5.68KB
  72. 资料day02/heima-leadnews-basic/heima-file-starter/pom.xml 1.53KB
  73. 资料day02/heima-leadnews-basic/heima-file-starter/src/
  74. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/
  75. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/
  76. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/
  77. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/
  78. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/
  79. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/config/
  80. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/config/MinIOConfig.java 1.05KB
  81. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/config/MinIOConfigProperties.java 474B
  82. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/service/
  83. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/service/FileStorageService.java 978B
  84. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/service/impl/
  85. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/java/com/heima/file/service/impl/MinIOFileStorageService.java 5.94KB
  86. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/resources/
  87. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/resources/META-INF/
  88. 资料day02/heima-leadnews-basic/heima-file-starter/src/main/resources/META-INF/spring.factories 119B
  89. 资料day02/heima-leadnews-basic/heima-file-starter/src/test/
  90. 资料day02/heima-leadnews-basic/heima-file-starter/src/test/java/
  91. 资料day02/heima-leadnews-basic/heima-file-starter/target/
  92. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/
  93. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/META-INF/
  94. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/META-INF/spring-configuration-metadata.json 948B
  95. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/META-INF/spring.factories 119B
  96. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/
  97. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/
  98. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/
  99. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/config/
  100. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/config/MinIOConfig.class 2.75KB
  101. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/config/MinIOConfigProperties.class 3.37KB
  102. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/service/
  103. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/service/FileStorageService.class 481B
  104. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/service/impl/
  105. 资料day02/heima-leadnews-basic/heima-file-starter/target/classes/com/heima/file/service/impl/MinIOFileStorageService.class 6.16KB
  106. 资料day02/heima-leadnews-basic/heima-file-starter/target/generated-sources/
  107. 资料day02/heima-leadnews-basic/heima-file-starter/target/generated-sources/annotations/
  108. 资料day02/heima-leadnews-basic/pom.xml 791B
  109. 资料day02/leadnews_article.sql 37.69KB
  110. 资料day02/模板文件/
  111. 资料day02/模板文件/article.ftl 8.5KB
  112. 资料day02/模板文件/plugins/
  113. 资料day02/模板文件/plugins/css/
  114. 资料day02/模板文件/plugins/css/index.css 2.16KB
  115. 资料day02/模板文件/plugins/js/
  116. 资料day02/模板文件/plugins/js/axios.min.js 14.02KB
  117. 资料day02/模板文件/plugins/js/index.js 15.02KB
0评论
提交 加载更多评论
其他资源 黑马头条(day01)资料
包含所用数据库脚本文件,前端项目,nginx,后端初始化项目
1049179415562896swing图书管理系统1(源码+详细报告).zip
1049179415562896swing图书管理系统1(源码+详细报告).zip
JegoV1.3.9.zip
JegoV1.3.9.zip
《全球高考》作者:木苏里.zip
《全球高考》作者:木苏里.zip
blender插件hardops
blender插件hardops
4BFF881B-5EE2-495C-A7A0-A5818A499374.zip
4BFF881B-5EE2-495C-A7A0-A5818A499374.zip
F4-perfCounter.zip
F4-perfCounter.zip
reactor demo
reactor demo