use bytes::Bytes;
use futures_lite::future::block_on;
fn main() -> Result<(), Box<dyn std::error::Error>> {
block_on(async move {
let client = ugi::Client::builder().build()?;
let body = async_stream::stream! {
yield Ok(Bytes::from_static(b"{\"step\":1}\n"));
yield Ok(Bytes::from_static(b"{\"step\":2}\n"));
};
let req = client
.post("https://upload.example.com/ingest")
.header("content-type", "application/x-ndjson")?
.body_stream(Box::pin(body));
let res = req.await?;
println!("upload status={}", res.status().as_u16());
Ok(())
})
}