diff --git a/src/main.rs b/src/main.rs index ed33190..ee19608 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,6 +109,39 @@ fn transpose_asset_id_file_map(asset_id_file_map:AssetIDFileMapBad)->AResultAResult<()>{ + let client=reqwest::Client::new(); + futures::stream::iter(asset_id_file_map) + .map(|(asset_id,file)|{ + let client=&client; + let cookie=cookie.as_str(); + let owner=&owner; + async move{ + let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")?; + { + let mut query=url.query_pairs_mut(); + query.append_pair("assetid",asset_id.to_string().as_str()); + match owner{ + Owner::Group(group_id)=>{query.append_pair("groupId",group_id.to_string().as_str());}, + Owner::User=>(), + } + } + + let resp=client.post(url) + .header("Cookie",cookie) + .body(tokio::fs::read_to_string(file).await?) + .send().await?; + Ok((asset_id,resp.bytes().await?)) + } + }) + .buffer_unordered(CONCURRENT_REQUESTS) + .for_each(|b:AResult<_>|async{ + match b{ + Ok((asset_id,body))=>{ + println!("asset_id={} response.body={:?}",asset_id,body); + }, + Err(e)=>eprintln!("ul error: {}",e), + } + }).await; Ok(()) }