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

minio私有桶授权访问

        <dependency><groupId>io.minio</groupId><artifactId>minio</artifactId><version>8.5.7</version> <!-- 使用最新版本 --></dependency>
MinioConfig:
package com.zy.datapickcli;import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class MinioConfig {@Value("${minio.endpoint}")private String endpoint;@Value("${minio.access-key}")private String accessKey;@Value("${minio.secret-key}")private String secretKey;@Bean // 确保方法返回 MinioClient 并添加 @Beanpublic MinioClient minioClient() {return MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();}
}
FileController:
package com.zy.datapickcli;import io.minio.GetPresignedObjectUrlArgs;
import io.minio.MinioClient;
import io.minio.http.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.concurrent.TimeUnit;@RestController
public class FileController {@Autowiredprivate MinioClient minioClient;@GetMapping("/presigned-url")public String getPresignedUrl() throws Exception {return generatePresignedUrl("kjwl", "20231008135220.png");}public String generatePresignedUrl(String bucketName, String objectName) throws Exception {return minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder().method(Method.GET).bucket(bucketName).object(objectName).expiry(1, TimeUnit.HOURS).build());}
}

yml:

minio:endpoint: http://127.0.0.1:9000access-key: xxxsecret-key: xxx

访问测试:

http://www.xdnf.cn/news/13290.html

相关文章:

  • Leetcode 3574. Maximize Subarray GCD Score
  • java 面向对象编程
  • Linux下制作Nginx绿色免安装包
  • 7.4.分块查找
  • vue3 字体颜色设置的多种方式
  • sysctl优先级顺序
  • 第3章 MySQL数据类型
  • (八)深度循环神经网络:长序列建模、注意力机制与多模态融合
  • CloudReadering
  • Prompt Tuning、P-Tuning、Prefix Tuning的区别
  • c语言中的hashmap
  • ArkUI-X跨平台Bridge最佳实践
  • 张彬彬《龙骨焚箱》开机 奇幻冒险题材引期待
  • 在微服务架构中,怎么搭建Maven私服
  • crackme007
  • mysql8.4备份与恢复实践
  • bilibili-mcp 使用示例
  • 7.6 Finetuning the LLM on instruction data
  • 论文分享 _ Ladder:一种基于收敛的结构化图区块链_2025-06-10
  • 实战案例-FPGA如何实现JESD204B可重复的延迟
  • 2005-2021年中国地下水位年鉴数据(EXCEL/PDF)包含:各省监测点、监测深度等
  • 【存储系统】
  • 理解 MCP 工作流:使用 Ollama 和 LangChain 构建本地 MCP 客户端
  • 全新AI驱动Workspace Security 套件发布!Fortinet 电子邮件安全产品矩阵升级
  • PHP 多种内置的验证规则和函数
  • 在Jenkins上配置邮箱通知
  • 2025-03-15-位运算
  • 第一部分 -- ①语法分析的概要
  • Yolov5.6增加注意力机制+ByterTrack:目标检测与跟踪
  • Linux(Centos 7.6)命令详解:find