🔥
Caster 開發日誌
  • Java
    • JVM Performance Tool
      • Java Debug Wire Protocol (JDWP) 的詳細介紹
      • JConsole 詳細介紹
    • Spring Boot
      • Spring Security
      • Spring Boot Admin
      • Spring Event
      • Spring AOP
      • Spring Boot JUnit 5
      • Apache Dubbo
    • Reflect 應用
    • ELK + F 建構
    • Socket.IO
    • OCR - 光學字元辨識
    • 讀取JAR resource文件
    • LocalTime & MySQL時間精度
    • Gradle multi module
    • MyBatis-Plus
    • Java Date operation
    • Java IP to Long
    • Apache Commons lang3 應用
      • Function 應用
    • Cloud Platform
      • Amazon S3
        • SDK V1
          • Bucket
        • SDK V2
          • Bucket
      • Google Cloud Platform
      • Azure Cloud
        • Storage
      • OVHcloud
        • Config
    • SSL/TLS工具
    • Util 工具
      • Jackson Json工具
      • Charles應用
      • JMeter – Performing Distributed Load Testing with Docker
    • Redis
      • Stream
      • Redisson 分布式鎖機制
      • Create Redis Cluster Using Docker
      • List Operations
    • Java 8
      • method & constructor Reference
      • CompletableFuture
      • FunctionInterface
      • Stream 應用
      • 繁簡轉換 - 簡易調整
    • MySQL
      • 建立測試用 流水號Table
      • SQL 效能調校 - Explain
      • SQL 效能調校 - Partition
      • 排程 - Event
    • Apache ShardingSphere
  • Kubernetes
    • 初入江湖(K8S)
    • 零中斷服務滾動更新
    • Kubernetes DNS
    • Ingress & Ingress Controller 教學
    • Ingress TLS Easy setup
  • 指令集
  • Telegram
  • SourceTree
    • 踩坑紀錄(ㄧ) - Git Flow
    • 踩坑紀錄(二) - 修改檔名
  • 專案統計
    • Robot
    • Recharge
  • GitHub
    • Actions
  • GitLab
    • 介紹 GitLab
    • 使用 Docker 自架 GitLab
    • 簡介 GitLab CI/CD
      • GitLab Runner 詳細介紹與設定方式
Powered by GitBook
On this page
  • 如何取得Key
  • SDK V1
  • SDK V2
  1. Java
  2. Cloud Platform
  3. OVHcloud

Config

Use AWS S3 Java SDK Setting

PreviousOVHcloudNextSSL/TLS工具

Last updated 1 year ago

OVH 文件上顯示說可以透過AWS S3 API 去使用,這樣就是可以直接使用AWS S3 Java SDK 去做認證並且對容器進行操作,就此開始了奇幻冒險.....

如何取得Key

SDK V1

@Configuration
public class AWSS3Config {

	@Value("${custom.aws.accessKey}")
	private String accessKey;

	@Value("${custom.aws.secretKey}")
	private String secretKey;

	@Value("${custom.aws.area}")
	private String area;
	
	@Bean
	public AmazonS3 createAWSS3Client() {
		AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);

		//set-up the client
		// LocationCode 在建立 object container 時選擇區域時那邊的清單. 用縮寫(Ps.大小寫似乎都可以使用) Ex.Beauharnois(BHS) -> BHS
		AmazonS3 s3client = AmazonS3ClientBuilder
				.standard()
				.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("https://s3.{LocationCode}.cloud.ovh.net", "{LocationCode}"))
				.withCredentials(new AWSStaticCredentialsProvider(credentials))
				.build();
		return s3client;
	}
}

SDK V2

@Configuration
public class AWSS3Config {
	@Value("${custom.aws.accessKey}")
	private String accessKey;
	@Value("${custom.aws.secretKey}")
	private String secretKey;
	@Bean
	public S3Client createAWSS3Client() {
		AwsBasicCredentials awsCreds = AwsBasicCredentials.create(accessKey, secretKey);
		return S3Client.builder()
				.endpointOverride(new URI("https://s3.{LocationCode}.cloud.ovh.net"))
				.region(Region.of("{LocationCode}"))
				.credentialsProvider(StaticCredentialsProvider.create(awsCreds)).build();
	}
}
首先找到User & Roles 這邊
生成S3 憑證Key
再自行複製下來
LocationCode List