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

MinIO图片正常上传不可查看,MinIO通过页面无法设置桶为public

项目场景:国产中标麒麟操作系统部署MinIO正常启动后发现图片能正常上传,但是匿名浏览该图片的时候无法查看。通过网络查询解决方案,得出的结论是:需要把当前上传文件的桶设置为public,由于创建桶默认是private且不可通过浏览器进行修改,最后决定通过使用java代码的方式进行桶权限的修改,在修改过程中遇到一些网络问题,在此总结。


问题一的描述

MinIO图片可正常上传,但无法进行在线浏览,在线修改桶权限自动退出页面,通过java代码进行桶权限修改。
一、MinIO图片可正常上传,但无法进行在线浏览
在这里插入图片描述二、查看MinIO网页确定图片已上传成功
在这里插入图片描述三、查看MinIO网页图片所属桶权限为private,需要把桶权限修改为public,使用超级管理员进行浏览器修改权限却自动退出登入,看有专业人士博客说是8.0后的版本都不可以通过浏览器进行桶权限修改。
在这里插入图片描述

问题一的解决方案:

	public static void main(String[] args) {String sb = "{\"Version\":\"2012-10-17\"," +"\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":" +"{\"AWS\":[\"*\"]},\"Action\":[\"s3:ListBucket\",\"s3:ListBucketMultipartUploads\"," +"\"s3:GetBucketLocation\"],\"Resource\":[\"arn:aws:s3:::" + BucketName +"\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:PutObject\",\"s3:AbortMultipartUpload\",\"s3:DeleteObject\",\"s3:GetObject\",\"s3:ListMultipartUploadParts\"],\"Resource\":[\"arn:aws:s3:::" +BucketName +"/*\"]}]}";MinioClient minioClient = MinioClient.builder().endpoint(MinIO地址).credentials(登入名, 密码).build();try {minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(BucketName).config(sb).build());} catch (ErrorResponseException e) {e.printStackTrace();} catch (InsufficientDataException e) {e.printStackTrace();} catch (InternalException e) {e.printStackTrace();} catch (InvalidKeyException e) {e.printStackTrace();} catch (InvalidResponseException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} catch (NoSuchAlgorithmException e) {e.printStackTrace();} catch (ServerException e) {e.printStackTrace();} catch (XmlParserException e) {e.printStackTrace();}}

问题二的描述

一、通过上述的描述已经可以解决我在互联网云服务器部署MinIO出现的问题,当我把上面代码运用在我那台政务互联网环境下国产麒麟服务器时,又报错了。
Exception in thread “main” java.io.IOException: unexpected end of stream on http://IP:9000/…
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.java:236)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:115)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
at okhttp3.RealCall.execute(RealCall.java:81)
at io.minio.MinioClient.execute(MinioClient.java:635)
at io.minio.MinioClient.execute(MinioClient.java:564)
at io.minio.MinioClient.executePut(MinioClient.java:903)
at io.minio.MinioClient.setBucketPolicy(MinioClient.java:3001)
at org.springblade.modules.system.controller.SetBucketPolicy.main(SetBucketPolicy.java:31)
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:240)
at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.java:242)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.java:213)
… 21 more

问题二的原因分析:

我咨询了人工智能,他认为可能网络、防火墙、OkHttp版本问题或服务器配置的问题


问题二的解决方案:

我思考了一下,在云服务器下可正常调用并成功修改桶权限那么该方法逻辑肯定是没有问题的,那我是否可以把我的java代码写成一个无需授权的GET接口,然后使用curl去调用该接口。

接下来对我的接口进行一些修改,注意我这里是特意修改IP为localhost,如果你和我问题一直,这个参数可以与我保持一致。然后使用 curl -X GET 127.0.0.1:java服务端口/当前服务的路径/setBucketPolicy命令执行,查看日志未报错,成功修改桶为public。

	@GetMapping("/setBucketPolicy")public void setBucketPolicy(){String sb = "{\"Version\":\"2012-10-17\"," +"\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":" +"{\"AWS\":[\"*\"]},\"Action\":[\"s3:ListBucket\",\"s3:ListBucketMultipartUploads\"," +"\"s3:GetBucketLocation\"],\"Resource\":[\"arn:aws:s3:::" + BucketName +"\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:PutObject\",\"s3:AbortMultipartUpload\",\"s3:DeleteObject\",\"s3:GetObject\",\"s3:ListMultipartUploadParts\"],\"Resource\":[\"arn:aws:s3:::" +BucketName +"/*\"]}]}";MinioClient minioClient = MinioClient.builder().endpoint("http://localhost:9000").credentials(登入名, 密码).build();try {minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(BucketName).config(sb).build());} catch (ErrorResponseException e) {e.printStackTrace();} catch (InsufficientDataException e) {e.printStackTrace();} catch (InternalException e) {e.printStackTrace();} catch (InvalidKeyException e) {e.printStackTrace();} catch (InvalidResponseException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} catch (NoSuchAlgorithmException e) {e.printStackTrace();} catch (ServerException e) {e.printStackTrace();} catch (XmlParserException e) {e.printStackTrace();}}

在这里插入图片描述 在这里插入图片描述
在这里插入图片描述
中标麒麟国产服务器安装MinIO地址:http://t.csdnimg.cn/zqXSk

http://www.lryc.cn/news/188547.html

相关文章:

  • Linux 指令心法(七)`cat` 查看、合并和创建文本文件
  • 解决docker开启MySQL的binlog无法成功。docker内部报错:mysql: [ERROR] unknown variable
  • c,python ,java,c++ c#在控制台打印彩色文本
  • MySQL数据库技术笔记(5)
  • python生成随机数
  • Twitter优化秘籍:置顶、列表、受众增长
  • vscode更改为中文版本
  • 【Linux系统KVM虚拟机实战】LVM逻辑卷之磁盘扩容
  • 史上最全 结构型模式之 桥接 外观 组合 享元模式
  • KBU810-ASEMI高性能整流桥KBU810
  • uniapp快速入门系列(2)- Vue基础知识
  • mac(M1)安装anaconda3
  • vscode远程ssh服务器且更改服务器别名
  • 【算法笔记】LCR 086. 分割回文串
  • centos 安装svn
  • Java中的类加载器双亲委派模型机制
  • [spring] spring jpa - hibernate 名词解释配置
  • java判断字符串是否为时间格式
  • 【Java】什么是API
  • Hazelcast系列(三):hazelcast集成(服务器/客户端)
  • vscode 配置默认shell
  • 品牌低价的形式有哪些
  • SPA项目之主页面--数据表格的增删改查
  • Adobe Premiere Pro:掌控视频剪辑的魔法之手,让你的创作腾飞!
  • ES知识点全面整理
  • 【电商API封装接口】电商百万商品资源一键导入,助力企业流量变现
  • bootz启动 Linux内核过程中涉及的全局变量images
  • Vuex的使用,详细易懂
  • 基于多线程的Reactor模式的 回声服务器 EchoServer
  • 《TWS蓝牙耳机通信原理与接口技术》