diff --git a/examples/client/Cargo.toml b/examples/client/Cargo.toml index a3d75a0..7d696c4 100644 --- a/examples/client/Cargo.toml +++ b/examples/client/Cargo.toml @@ -8,7 +8,7 @@ publish = false adapter = "wasi_snapshot_preview1.command.wasm" [dependencies] -waki = { version = "0.2.0", features = ["json"] } +waki = { version = "0.3.0", features = ["json", "multipart"] } serde = { version = "1.0.202", features = ["derive"] } # reduce wasm binary size diff --git a/examples/client/src/main.rs b/examples/client/src/main.rs index 29b1d6d..4fb5313 100644 --- a/examples/client/src/main.rs +++ b/examples/client/src/main.rs @@ -1,7 +1,10 @@ use serde::Deserialize; use std::collections::HashMap; use std::time::Duration; -use waki::Client; +use waki::{ + multipart::{Form, Part}, + Client, +}; #[derive(Debug, Deserialize)] #[allow(dead_code)] @@ -76,19 +79,13 @@ fn main() { // post with file form data let resp = Client::new() .post("https://httpbin.org/post") - .header("Content-Type", "multipart/form-data; boundary=boundary") - .body( - "--boundary -Content-Disposition: form-data; name=field1 - -value1 ---boundary -Content-Disposition: form-data; name=field2; filename=file.txt -Content-Type: text/plain - -hello ---boundary--" - .as_bytes(), + .multipart( + Form::new().text("field1", "value1").part( + Part::new("field2", "hello") + .filename("file.txt") + .mime_str("text/plain") + .unwrap(), + ), ) .connect_timeout(Duration::from_secs(5)) .send() diff --git a/examples/server/Cargo.toml b/examples/server/Cargo.toml index 7d3d6a4..477529c 100644 --- a/examples/server/Cargo.toml +++ b/examples/server/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] adapter = "wasi_snapshot_preview1.proxy.wasm" [dependencies] -waki = "0.2.0" +waki = "0.3.0" # reduce wasm binary size [profile.release]