Skip to content

How to use S3 client with Localstack? #874

Answered by 0nkery
0nkery asked this question in Q&A
Discussion options

You must be logged in to vote

UPD: It's not required, I could just use builder.force_path_style(true) (thanks to rcoh).

Solved the issue with this custom endpoint resolver:

pub struct ForceBucketInPathResolver {
    base_resolver: Endpoint,
}

impl ResolveEndpoint<aws_sdk_s3::config::endpoint::Params> for ForceBucketInPathResolver {
    fn resolve_endpoint(&self, params: &aws_sdk_s3::config::endpoint::Params) -> aws_smithy_http::endpoint::Result {
        match params.bucket() {
            Some(bucket) => self.base_resolver.resolve_endpoint(params).map(|ep| {
                let url = ep.url().to_owned();
                ep.into_builder().url(format!("{url}{bucket}")).build()
            }),
            None => self.b…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@rcoh
Comment options

rcoh Aug 22, 2023
Collaborator

@0nkery
Comment options

Answer selected by 0nkery
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants