[英]Configure java AWS sdk client to write to local S3 bucket (localstack)
So i am able to configure a local s3 bucket using localstack with the following command所以我可以通过以下命令使用 localstack 配置本地 s3 存储桶
aws --endpoint-url=http://localhost:4572 s3 mb s3://mytestbucket
How am I able to change the configuration for the java AWS SDK in order to write/read from/to this bucket instead of remote aws s3?我如何能够更改 java AWS SDK 的配置,以便从/读取此存储桶而不是远程 aws s3?
I have looked at the configuration but not able to find any tangible我查看了配置,但找不到任何有形的
This is done via the endpoint configuration within the AWS S3 SDK when creating the client.这是在创建客户端时通过 AWS S3 开发工具包中的端点配置完成的。 For example:
例如:
final AwsClientBuilder.EndpointConfiguration endpoint = new AwsClientBuilder.EndpointConfiguration(s3Endpoint, REGION);
final AmazonS3 client = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(endpoint)
.build();
The endpoint can be a string like http://localhost:4572
(where the port number needs to be whatever port s3 in localstack is listening on - by default 4572)端点可以是类似
http://localhost:4572
的字符串(其中端口号需要是 localstack 中正在侦听的任何端口 s3 - 默认情况下为 4572)
Now the s3 endpoint is updated in localstack .现在 s3 端点在 localstack 中更新。
Please use the below url : http://s3.localhost.localstack.cloud:4566请使用以下网址: http ://s3.localhost.localstack.cloud:4566
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.