Zig
Zig
Wasabi Download File
See more Wasabi Examples
Demonstrates how to download a file from a Wasabi bucket.Chilkat Zig Downloads
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 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("access-key");
// Insert your secret key here:
http.setAwsSecretKey("secret-key");
// Use the endpoint matching the bucket's region.
http.setAwsEndpoint("s3.us-west-1.wasabisys.com");
const bucket_name = "chilkat-west";
const object_name = "seahorse.jpg";
const local_file_path = "c:/temp/qa_output/seahorse.jpg";
success = if (http.s3DownloadFile(bucket_name, object_name, local_file_path)) true else |_| false;
if (!success) {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
} else {
std.debug.print("File downloaded.\n", .{});
}
}