Sample code for 30+ languages & platforms
Zig Requires Chilkat v9.5.0.89+

Wasabi FTP Download

See more Wasabi Examples

Demonstrates how to download a file from a Wasabi bucket using FTP.

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 assumes the Chilkat HTTP API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const ftp = try chilkat.Ftp2.init();
    defer ftp.deinit();

    // Use the domain for the bucket you'll be managing.
    ftp.setHostname("s3.s3.us-west-1.wasabisys.com");

    // Use your root account username (email address) and root account password
    ftp.setUsername("root_account_username");
    ftp.setPassword("root_account_password");
    ftp.setSsl(true);
    ftp.setPort(990);

    ftp.connect() catch {
        std.debug.print("{s}\n", .{try ftp.getLastErrorText(alloc)});
        return;
    };

    // Upload a file (starfish.jpg) to the bucket named "chilkat"
    const local_file_path = "qa_output/starfish.jpg";
    const remote_bucket_path = "/chilkat/starfish.jpg";
    ftp.getFile(remote_bucket_path, local_file_path) catch {
        std.debug.print("{s}\n", .{try ftp.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("File uploaded.\n", .{});
}