Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.0.0+

Backblaze S3 Delete Bucket Objects

See more Backblaze S3 Examples

Demonstrates how to delete objects in 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();

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

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

    // keyID = Access Key ID or Access Key
    http.setAwsAccessKey("access-key");

    // applicationKey = Secret Access Key or Secret Key
    http.setAwsSecretKey("secret-key");

    // Region is the 2nd part of your S3 Endpoint
    http.setAwsEndpoint("s3.us-west-002.backblazeb2.com");

    const bucket_name = "chilkat-test";

    const object_name1 = "seahorse.jpg";
    const object_name2 = "orchard.json";

    const st = try chilkat.StringTable.init();
    defer st.deinit();
    st.append(object_name1) catch {};
    st.append(object_name2) catch {};

    const json_resp = try chilkat.JsonObject.init();
    defer json_resp.deinit();
    http.s3DeleteObjects(bucket_name, st, json_resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("Response status code = {d}\n", .{http.getLastStatus()});

    // Display the JSON response.
    json_resp.setEmitCompact(false);
    std.debug.print("{s}\n", .{try json_resp.emit(alloc)});
}