feat: update osssendfile-rs
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
use clap::Parser;
|
||||
use rust_util::{opt_result, opt_value_result, util_file, XResult};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
const OSS_SEND_FILE_CONFIG_FILE: &str = "~/.jssp/config/osssendfile.json";
|
||||
const CREATE_STS_URL: &str = "https://hatter.ink/oidc/create_sts.json";
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct OssSendFileConfig {
|
||||
@@ -48,13 +52,25 @@ struct OssSendFileArgs {
|
||||
keywords: Option<String>,
|
||||
}
|
||||
|
||||
fn main() -> XResult<()> {
|
||||
#[tokio::main]
|
||||
async fn main() -> XResult<()> {
|
||||
let args = OssSendFileArgs::parse();
|
||||
let oss_send_file_config = load_config(&args.config)?;
|
||||
|
||||
println!("{:?}", args);
|
||||
println!("{:?}", oss_send_file_config);
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let mut params = HashMap::new();
|
||||
params.insert("client_id", &oss_send_file_config.oidc.client_id);
|
||||
params.insert("client_secret", &oss_send_file_config.oidc.client_secret);
|
||||
params.insert("sub", &oss_send_file_config.oidc.sub);
|
||||
let response = client.post(CREATE_STS_URL)
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
// TODO ...
|
||||
|
||||
Ok(())
|
||||
@@ -63,7 +79,7 @@ fn main() -> XResult<()> {
|
||||
fn load_config(config: &Option<String>) -> XResult<OssSendFileConfig> {
|
||||
let config_file_opt = util_file::read_config(
|
||||
config.clone(),
|
||||
&["~/.jssp/config/osssendfile.json".to_string()],
|
||||
&[OSS_SEND_FILE_CONFIG_FILE.to_string()],
|
||||
);
|
||||
let config_file = opt_value_result!(config_file_opt, "Config file not found.");
|
||||
let config = opt_result!(
|
||||
|
||||
Reference in New Issue
Block a user