当前位置: 首页 > news >正文

做网站专题怎样添加微博什么是seo和sem

做网站专题怎样添加微博,什么是seo和sem,最优的锦州网站建设,公众号开发培训MinIO 是一种开源的对象存储服务,它基于云原生架构构建,并提供了高性能、易于扩展和安全的存储解决方案。 一.安装和配置 MinIO 服务器 为了演示方便,本文采用Windows安装 1.在官方网站下载MinIO 安装文件,地址:ht…

MinIO 是一种开源的对象存储服务,它基于云原生架构构建,并提供了高性能、易于扩展和安全的存储解决方案。

一.安装和配置 MinIO 服务器

为了演示方便,本文采用Windows安装 

1.在官方网站下载MinIO 安装文件,地址:https://dl.minio.org.cn/server/minio/release/windows-amd64/minio.exe; 

2.在minio.exe目录下创建start.bat配置启动文件:"D:\Java\MinIo"是服务启动时文件存放的位置 

minio.exe server D:\Java\MinIo

3.双击minio.exe文件启动

 

4.创建一个 Spring Boot 项目

        1.创建一个 Spring Boot 项目

        2.添加依赖,注意依赖版本

<!--文件上传-->
<dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version>
</dependency>
<dependency><groupId>commons-fileupload</groupId><artifactId>commons-fileupload</artifactId><version>1.4</version>
</dependency><!--MinIO对象存储-->
<dependency><groupId>io.minio</groupId><artifactId>minio</artifactId><version>8.4.3</version>
</dependency>
<dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.8.1</version>
</dependency>

二.配置文件

        1.yaml配置文件

#MinIO配置
minio:endpoint: http://127.0.0.01:9000 #连接地址accessKey: minioadmin#账号 默认minioadminsecretKey: minioadmin#密码 默认minioadminbucketName: contractfile #桶名 存放合同文件 桶名校验规则:!name.matches("^[a-z0-9][a-z0-9\\.\\-]+[a-z0-9]$")

         2.配置类,用来连接Minio

@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {//连接地址private String endpoint;//账号 默认minioadminprivate String accessKey;//密码 默认minioadminprivate String secretKey;@Beanpublic MinioClient minioClient() {MinioClient minioClient = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();return minioClient;}}

        3.工具类,用来操作文件

@Slf4j
@Component
public class MinioUtils {@Autowiredprivate MinioClient minioClient;@Value("${minio.bucketName}")private String bucketName;/*** 操作文件时先创建Bucket* 如果没有Bucket则创建** @param bucketName*/@SneakyThrows(Exception.class)public void createBucket(String bucketName) {if (!bucketExists(bucketName)) {minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());}}/*** 判断Bucket是否存在,true:存在,false:不存在** @param bucketName* @return*/@SneakyThrows(Exception.class)public boolean bucketExists(String bucketName) {return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());}/*** 判断文件是否存在** @param bucketName* @param fileRealName* @return*/public boolean isObjectExist(String bucketName, String fileRealName) {boolean exist = true;try {minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(fileRealName).build());} catch (Exception e) {log.error("[Minio工具类]>>>> 判断文件是否存在, 异常:", e);exist = false;}return exist;}/*** 使用MultipartFile进行文件上传** @param bucketName   存储桶* @param file         文件* @param fileRealName 文件名* @return 文件下载外链*/@SneakyThrows(Exception.class)public String uploadFile(String bucketName, MultipartFile file, String fileRealName) {createBucket(bucketName);InputStream inputStream = file.getInputStream();minioClient.putObject(PutObjectArgs.builder().bucket(bucketName).object(fileRealName).contentType(file.getContentType()).stream(inputStream, inputStream.available(), -1).build());GetPresignedObjectUrlArgs args = GetPresignedObjectUrlArgs.builder().bucket(bucketName).object(fileRealName).method(Method.GET).build();return minioClient.getPresignedObjectUrl(args);}/*** 删除文件** @param bucketName   存储桶* @param fileRealName 文件名称*/@SneakyThrows(Exception.class)public void removeFile(String bucketName, String fileRealName) {createBucket(bucketName);minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(fileRealName).build());}/*** 下载文件** @param httpServletResponse httpServletResponse* @param fileRealName        文件存储名称* @param fileName            文件下载名称* @throws IOException IOException*/public void downloadFile(String bucketName, String fileRealName, String fileName, HttpServletResponse httpServletResponse) throws Exception {createBucket(bucketName);//获取文件流InputStream inputStream = minioClient.getObject(GetObjectArgs.builder().bucket(bucketName).object(fileRealName).build());//设置响应头信息,告诉前端浏览器下载文件httpServletResponse.setContentType("application/octet-stream;charset=UTF-8");httpServletResponse.setCharacterEncoding("UTF-8");httpServletResponse.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));//获取输出流进行写入数据OutputStream outputStream = httpServletResponse.getOutputStream();// 将输入流复制到输出流byte[] buffer = new byte[4096];int bytesRead = -1;while ((bytesRead = inputStream.read(buffer)) != -1) {outputStream.write(buffer, 0, bytesRead);}// 关闭流资源inputStream.close();outputStream.close();}
}

http://www.khdw.cn/news/27355.html

相关文章:

  • 织梦手机网站怎么做大连seo网站推广
  • 网站重构div css论文西安seo服务
  • 网站优化怎么做 有什么技巧免费下载app并安装
  • 地方门户网站运营网络推广计划书范文
  • 手机非法网站怎么解决方案凡科建站收费价目表
  • 游戏推广赚佣金seo排名优化资源
  • 张家港市做网站的公司宣传软文案例
  • 怎样清除单位域名 网站或互联网网址关键词搜索优化外包
  • wordpress theme o'connor关键词优化快排
  • wordpress怎么写时间轴石家庄seo代理商
  • 合肥 网站设计站外推广渠道有哪些
  • 制作网页需要学什么语言seo学徒招聘
  • 小学网站源码php网上引流推广怎么做
  • 计算机网站开发要考什么证seo自学
  • 西部数码网站源码东莞百度seo推广公司
  • 佛山新网站制作公司搜索引擎优化英文简称为
  • .net网站开发实训代码自己做一个网站
  • 网站上线 文案网站流量
  • 类似天书奇谈的网页游戏教程推广优化网站排名
  • 做第三方网站注意什么网络营销题库及答案2020
  • 2008建设网站绍兴seo优化
  • 铭誉摄影网站b2b网站大全免费
  • 苏州做网站推广的网络推广网站建设
  • 网站诊断seo当前数据是指百度账号登录个人中心
  • 做网站图片显示不来百度网盘资源搜索引擎搜索
  • 官网站站百度如何推广产品
  • 办网站怎么赚钱免费网站seo诊断
  • 沈阳网站关键词优化济南seo优化外包服务
  • 聊城网站建设招聘网站快速排名互点软件
  • 百度推广入口登录金华seo扣费