#HTTPS PUT file

1 messages · Page 1 of 1 (latest)

sand moon
#

I'd like to upload a file to a server using zig, it would be equivalent to curl --upload-file myfile.png https://server.com

zig's http/net functionality in stdlib looks pretty empty - whats my best option short of spawning a childprocess for curl?

#

HTTPS PUT file

leaden shell
#
    const ChildProc = @import("std").ChildProcess;
    var child_proc = ChildProcess.init(
        &.{ curl_path, "--upload-file", "myfile.png", "https://server.com" },
        gpa,
    ); //curl_path can be just curl, if it is in your PATH or otherwise relative or absolute path
    try child_proc.spawn();
    const ret_val = try child_proc.wait();
    try testing.expectEqual(ret_val, .{ .Exited = 0 });
sand moon
#

thanks - I guess you missed the part where I asked what my options are besides spawning a child process 😆.

leaden shell
sand moon
#

rad, thanks

deft perch