Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateBucket won't work without LocationConstraint for non-default regions #78

Open
ryanbutterfield opened this issue Jun 14, 2023 · 0 comments

Comments

@ryanbutterfield
Copy link

ryanbutterfield commented Jun 14, 2023

For S3, I found I couldn't use CreateBucket wihout also providing a CreateBucketConfiguration with a LocationConstraint if the region wasn't the default region of us-east-1.

eg.

let action = CreateBucket::new(&self.bucket, &self.credentials);

let body = vec![
    r#"<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">"#,
    &format!(
        "<LocationConstraint>{}</LocationConstraint>",
        self.bucket.region()
    ),
    "</CreateBucketConfiguration>",
]
.join("");

self.client
    .put(action.sign(ONE_HOUR))
    .body(Body::from(body))
    .send()?
    .error_for_status()?;

Recommend adding a .body() function to CreateBucket, similar to how CompleteMultipartUpload provides a .body().

Ps. Thank you for this library. Apart from this, it works perfectly, and was the first non-async S3 library I could get working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant