简体   繁体   English

配置 java AWS sdk 客户端写入本地 S3 存储桶 (localstack)

[英]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.

相关问题 AWS Lambda Java,写入 S3 存储桶 - AWS Lambda Java, write to S3 bucket 使用 Java sdk 删除 aws s3 存储桶中的文件夹 - Delete a folder in aws s3 bucket using Java sdk 如何使用 AWS Java SDK for S3 查询 AWS S3 存储桶以匹配对象(文件)名称 - how to query AWS S3 bucket for matching objects(files) names using AWS Java SDK for S3 带有 Localstack 的 AWS S3 在 Java 应用程序中返回 500 - AWS S3 with Localstack return 500 in a Java application 将图像上传到S3 Bucket - Java SDK - Uploading Image to S3 Bucket - Java SDK 使用 AWS SDK 为 Java 创建 Amazon S3 存储桶:线程“主”java.lang.NoClassDefFoundError 中的异常 - Creating an Amazon S3 bucket Using the AWS SDK for Java : Exception in thread "main" java.lang.NoClassDefFoundError AWS S3(使用 localstack - 本地 AWS 版本)GET Presigned URL 问题 - AWS S3 (using localstack - a local AWS version) GET Presigned URL issue 如何使用AWS Java SDK从S3存储桶中的字节创建文件(如果尚不存在) - How to create File from bytes in S3 Bucket if it does not exist yet using AWS Java sdk 使用 aws-sdk-java 上传到 S3 存储桶时出现永久重定向错误 - PermanentRedirect error while uploading to S3 bucket with aws-sdk-java 将文件上传到 Amazon S3 存储桶。 使用适用于 Java v2 的 AWS 开发工具包 - Issuing uploading file to Amazon S3 Bucket. using the AWS SDK for Java v2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM