Skip to content

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

@ryanbutterfield

Description

@ryanbutterfield

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions