wip upload
This commit is contained in:
parent
e323becfbf
commit
5b68f23755
33
src/main.rs
33
src/main.rs
@ -109,6 +109,39 @@ fn transpose_asset_id_file_map(asset_id_file_map:AssetIDFileMapBad)->AResult<Ass
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn upload_list(cookie:String,owner:Owner,asset_id_file_map:AssetIDFileMap)->AResult<()>{
|
async fn upload_list(cookie:String,owner:Owner,asset_id_file_map:AssetIDFileMap)->AResult<()>{
|
||||||
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user