天津网站建设icp备,大连服务公司 网站,网页设计与制作课程教学中经常遇到的问题,网站内容策略项目场景#xff1a;国产中标麒麟操作系统部署MinIO正常启动后发现图片能正常上传#xff0c;但是匿名浏览该图片的时候无法查看。通过网络查询解决方案#xff0c;得出的结论是#xff1a;需要把当前上传文件的桶设置为public,由于创建桶默认是private且不可通过浏览器进行…项目场景国产中标麒麟操作系统部署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: limit0 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