From 158ecbb2b242f379db9ca1476cfb1f2959e9f7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B0=8F=E5=B9=B3?= Date: Sat, 1 Jun 2024 01:07:54 +0800 Subject: [PATCH] =?UTF-8?q?bucketExists=E8=B0=83=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../minio-plus-api-wrapper-official/pom.xml | 4 ++++ .../src/test/java/MinIORestful.java | 15 ++++++++++----- .../src/main/resources/application.yml | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/minio-plus-api-wrapper/minio-plus-api-wrapper-official/pom.xml b/minio-plus-api-wrapper/minio-plus-api-wrapper-official/pom.xml index 844151bcd..c45b191ea 100644 --- a/minio-plus-api-wrapper/minio-plus-api-wrapper-official/pom.xml +++ b/minio-plus-api-wrapper/minio-plus-api-wrapper-official/pom.xml @@ -28,6 +28,10 @@ okhttp 4.11.0 + + cn.hutool + hutool-all + \ No newline at end of file diff --git a/minio-plus-api-wrapper/minio-plus-api-wrapper-official/src/test/java/MinIORestful.java b/minio-plus-api-wrapper/minio-plus-api-wrapper-official/src/test/java/MinIORestful.java index 42ec73ec7..d671a8343 100644 --- a/minio-plus-api-wrapper/minio-plus-api-wrapper-official/src/test/java/MinIORestful.java +++ b/minio-plus-api-wrapper/minio-plus-api-wrapper-official/src/test/java/MinIORestful.java @@ -9,6 +9,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.google.common.io.BaseEncoding; +import io.minio.Digest; import javax.crypto.Mac; @@ -37,7 +38,11 @@ public class MinIORestful { // 动态传入参数 String url = "http://localhost:9000/document"; - HttpResponse httpResponse = request(url,"","/document","head"); +// ZonedDateTime date = ZonedDateTime.parse("2024-05-31T16:31:54Z"); + // 取得当前时间 + ZonedDateTime date = ZonedDateTime.now(); + + HttpResponse httpResponse = request(url,"","/document","HEAD",date); System.out.println("httpResponse.isOk()="+httpResponse.isOk()); System.out.println("httpResponse.getStatus()="+httpResponse.getStatus()); @@ -46,10 +51,9 @@ public class MinIORestful { } - public static HttpResponse request(String url,String params,String path,String method) throws NoSuchAlgorithmException, InvalidKeyException { + public static HttpResponse request(String url,String params,String path,String method,ZonedDateTime date) throws NoSuchAlgorithmException, InvalidKeyException { + - // 取得当前时间 - ZonedDateTime date = ZonedDateTime.now(); // 创建除Authorization外所有header Map> headers = new HashMap<>(); @@ -173,7 +177,8 @@ public class MinIORestful { ,String canonicalQueryString,String method,String path) throws NoSuchAlgorithmException { String canonicalRequest = method + "\n" + path + "\n" + canonicalQueryString + "\n" - + Joiner.on("\n").withKeyValueSeparator(":").join(canonicalHeaders) + "\n\n" + signedHeaders + "\n" + "x-amz-content-sha256"; + + Joiner.on("\n").withKeyValueSeparator(":").join(canonicalHeaders) + "\n\n" + signedHeaders + "\n" + ZERO_SHA256_HASH; + System.out.println("canonicalRequest="+canonicalRequest); return Digest.sha256Hash(canonicalRequest); } diff --git a/minio-plus-application/minio-plus-application-mysql/src/main/resources/application.yml b/minio-plus-application/minio-plus-application-mysql/src/main/resources/application.yml index 776c8fbf9..efc249a4d 100644 --- a/minio-plus-application/minio-plus-application-mysql/src/main/resources/application.yml +++ b/minio-plus-application/minio-plus-application-mysql/src/main/resources/application.yml @@ -25,11 +25,11 @@ spring: #驱动名称 driver-class-name: com.mysql.cj.jdbc.Driver #链接地址 - url: jdbc:mysql://localhost:3306/minio_plus?characterEncoding=UTF-8&useSSL=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://192.168.50.141:3306/minio-plus?characterEncoding=UTF-8&useSSL=true&serverTimezone=Asia/Shanghai #用户名 - username: root + username: minio #密码 - password: root + password: minioadmin ################################################################## # 服务器 ##################################################################