解决minio Non-XML response from server 问题(kusphere搭建的minio)

解决minio Non-XML response from server 问题(kubesphere安装的minio)

1、问题:

在这里插入图片描述

原因是 minio 的Api调用的地址端口为9000(不管是docker安装还是怎么样 只要确认自己将api 的端口暴露了即可调用成功) 但是我在kubesphere上安装的minio暴露的端口是9001 客户端的访问端口

解决方案:

就是再次配置一个nodepord 的服务即可

  • 在这里插入图片描述

  • 在这里插入图片描述

  • 第三步:在这里插入图片描述

之后将地址端口替换为api 的nodepord 即可:在这里插入图片描述

2、demo

将本地的一个list.html 文件上传到minio上

  • list.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <h1>Hello</h1>
    </body>
    </html>
    
    
  • 上传demo

    package com.xc.minio;
    
    import io.minio.MinioClient;
    import io.minio.PutObjectArgs;
    import org.springframework.boot.test.context.SpringBootTest;
    
    import java.io.FileInputStream;
    
    /**
     * @project heima-leadnews
     * @description
     * @author capture or new
     * @date 2023/7/14 13:42:53
     * @version 1.0
     */
    
    public class MinioTest {
          
          
        public static void main(String[] args) {
          
          
            FileInputStream fileInputStream = null;
            try {
          
          
    
                // 本地文件地址
                fileInputStream =  new FileInputStream("D:\\project\\heimatoutiao\\资料\\初始工程\\heima-leadnews\\heima-leadnews\\heima-leadnews-test\\minio-demo\\src\\main\\resources\\templates\\list.html");;
    
                //1.创建minio链接客户端
                MinioClient minioClient = MinioClient.builder().credentials("username", "password")
                        .endpoint("http://10.13.167.16:31255")
                        .build();
                //2.上传
                PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                        .object("list.html")//文件名
                        .contentType("text/html")//文件类型
                        .bucket("leadnews")//桶名词  与minio创建的名词一致
                        //   fileInputStream.available() 表示一直有内容就会上传  -1 表示将所有的相关文件的内容都上传
                        .stream(fileInputStream, fileInputStream.available(), -1) //文件流
                        .build();
                minioClient.putObject(putObjectArgs);
                // 输出访问地址
                System.out.println("http://10.13.167.16:31255/leadnews/list.html");
    
            } catch (Exception ex) {
          
          
                ex.printStackTrace();
            }
        }
    }
    
    

3、访问

在这里插入图片描述

注意点 要将 这个桶的权限设置为public并设置为读写都ok的模式即可在点击链接后在浏览器中看到。
在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_63946922/article/details/131722701