commands/mb.rs

fractalbits · crates/fractal-s3/src/commands/mb.rs · rust · Apache-2.0
pos

Creates an S3 bucket from a given URI, validating input.

// Source: https://github.com/fractalbits-labs/fractalbits | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
use aws_sdk_s3::Client;

use crate::s3_path::S3Path;

pub async fn execute(client: &Client, s3_uri: &str) -> anyhow::Result<()> {
    let path = S3Path::parse(s3_uri)?;

    match path {
        S3Path::S3 { bucket, key } => {
            if !key.is_empty() {
                anyhow::bail!("mb command only accepts bucket names (s3://BUCKET), not keys");
            }
            create_bucket(client, &bucket).await
        }
        S3Path::Local(_) => {
            anyhow::bail!("mb command requires an S3 URI (s3://BUCKET)")
        }
    }
}

async fn create_bucket(client: &

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key