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

S3 Delete Multiple Objects

See more Amazon S3 Examples

Demonstrates how to delete multiple objects in a single HTTP request.

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();

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

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

    const bucket_name = "chilkattestbucket";

    const object_name1 = "starfish.jpg";
    // Delete a particular version of this object:
    const object_name2 = "conch.jpg; VersionId=\"3/L4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo\"";
    const object_name3 = "seaUrchin.jpg";

    const st = try chilkat.StringTable.init();
    defer st.deinit();
    st.append(object_name1) catch {};
    st.append(object_name2) catch {};
    st.append(object_name3) 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;
    };

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