Sample code for 30+ languages & platforms
Zig

S3 Delete Bucket

See more Amazon S3 Examples

Demonstrates how to delete a bucket.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    var success: bool = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const http = try chilkat.Http.init();
    defer http.deinit();

    // Insert your access key here:
    http.setAwsAccessKey("ABQXXABC83ABCDEFVQXX");

    // Insert your secret key here:
    http.setAwsSecretKey("XXXXYYYYabcdABCD12345678xxxxyyyyzzzz");

    http.setKeepResponseBody(true);

    success = if (http.s3DeleteBucket("chilkattestbucket")) true else |_| false;
    if (!success) {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        // Also examine the error response body from AWS:
        std.debug.print("{s}\n", .{try http.getLastResponseBody(alloc)});
    } else {
        std.debug.print("Bucket deleted.\n", .{});
    }
}