Zig
Zig
Example: Http.S3_FileExists method
Demonstrates theS3_FileExists method.
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const http = try chilkat.Http.init();
defer http.deinit();
// Insert your AWS keys here:
http.setAwsAccessKey("AWS_ACCESS_KEY");
http.setAwsSecretKey("AWS_SECRET_KEY");
const bucket_name = "chilkat.ocean";
const object_name = "seahorse.jpg";
http.setAwsRegion("us-west-2");
http.setAwsEndpoint("s3-us-west-2.amazonaws.com");
const retval = http.s3FileExists(bucket_name, object_name);
if (retval < 0) {
std.debug.print("Failed to check for the S3 object existence\n", .{});
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
}
if (retval == 0) {
std.debug.print("The S3 object does not exist.\n", .{});
return;
}
std.debug.print("The S3 object exists.\n", .{});
}