Solve the problem of minio Non-XML response from server (minio built by kusphere)

Solve the problem of minio Non-XML response from server (minio installed by kubesphere)

1. Question:

insert image description here

The reason is that the address port of minio's Api call is 9000 (whether it is docker installation or whatever, as long as you confirm that you have exposed the port of the api, the call can be successful), but the port exposed by minio installed on kubesphere is 9001, which is the access port of the client

solution:

Just configure a nodepord service again

  • insert image description here

  • insert image description here

  • third step:insert image description here

Then replace the address port with the nodepord of the api:insert image description here

2、demo

Upload a local list.html file to minio

  • list.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <h1>Hello</h1>
    </body>
    </html>
    
    
  • upload 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. Access

insert image description here

Pay attention to set the permission of this bucket to public and set it to a mode where both reading and writing are ok, and you can see it in the browser after clicking the link.
insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/qq_63946922/article/details/131722701