wip
This commit is contained in:
parent
dc2be28874
commit
6801f8101d
BIN
src/.DS_Store
vendored
Normal file
BIN
src/.DS_Store
vendored
Normal file
Binary file not shown.
@ -89,7 +89,7 @@ impl Client {
|
|||||||
let request = client
|
let request = client
|
||||||
.get(format!(
|
.get(format!(
|
||||||
"https://forest.sendy.jp/cloud/service/file/v1/filelink/token?host_id={}&path={}",
|
"https://forest.sendy.jp/cloud/service/file/v1/filelink/token?host_id={}&path={}",
|
||||||
self.host_id, "hello"
|
self.host_id, ""
|
||||||
))
|
))
|
||||||
.bearer_auth(&self.token.read().await);
|
.bearer_auth(&self.token.read().await);
|
||||||
|
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -52,20 +52,29 @@ impl RakutenDriveClient {
|
|||||||
fake_size: Option<u64>,
|
fake_size: Option<u64>,
|
||||||
pb: Option<indicatif::ProgressBar>,
|
pb: Option<indicatif::ProgressBar>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
let prefix = if prefix.unwrap_or("") == "/" {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
prefix.unwrap_or("")
|
||||||
|
};
|
||||||
let req = types::request::CheckUploadRequest {
|
let req = types::request::CheckUploadRequest {
|
||||||
host_id: self.client.host_id.clone(),
|
host_id: self.client.host_id.clone(),
|
||||||
path: prefix.unwrap_or("").to_string(),
|
path: prefix.to_string(),
|
||||||
upload_id: "".to_string(),
|
|
||||||
file: files
|
file: files
|
||||||
.iter()
|
.iter()
|
||||||
.map(|file| types::request::CheckUploadRequestFile {
|
.map(|file| types::request::CheckUploadRequestFile {
|
||||||
path: file.path.clone(),
|
path: file.path.clone(),
|
||||||
size: fake_size.unwrap_or(file.data.len() as u64) as i64,
|
size: fake_size.unwrap_or(file.data.len() as u64) as i64,
|
||||||
|
version_id: None,
|
||||||
|
host_id: None,
|
||||||
|
hash: None,
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("prefix: {:?}", prefix.unwrap_or(""));
|
println!("{:#?}", req);
|
||||||
|
|
||||||
|
// println!("prefix: {:?}", prefix.unwrap_or(""));
|
||||||
|
|
||||||
let check_upload_res = self.client.check_upload(req).await.unwrap();
|
let check_upload_res = self.client.check_upload(req).await.unwrap();
|
||||||
|
|
||||||
@ -202,17 +211,26 @@ impl RakutenDriveClient {
|
|||||||
fake_size: Option<u64>,
|
fake_size: Option<u64>,
|
||||||
pb: Option<indicatif::ProgressBar>,
|
pb: Option<indicatif::ProgressBar>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
let prefix = if prefix.unwrap_or("") == "/" {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
prefix.unwrap_or("")
|
||||||
|
};
|
||||||
let req = types::request::CheckUploadRequest {
|
let req = types::request::CheckUploadRequest {
|
||||||
host_id: self.client.host_id.clone(),
|
host_id: self.client.host_id.clone(),
|
||||||
path: prefix.unwrap_or("").to_string(),
|
path: prefix.to_string(),
|
||||||
upload_id: "".to_string(),
|
|
||||||
file: vec![types::request::CheckUploadRequestFile {
|
file: vec![types::request::CheckUploadRequestFile {
|
||||||
path: file.file.to_str().unwrap().to_string(),
|
path: file.file.to_str().unwrap().to_string(),
|
||||||
size: fake_size.unwrap_or(file.file.metadata().unwrap().len() as u64) as i64,
|
size: fake_size.unwrap_or(file.file.metadata().unwrap().len() as u64) as i64,
|
||||||
|
hash: None,
|
||||||
|
host_id: None,
|
||||||
|
version_id: None,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("prefix: {:?}", prefix.unwrap_or(""));
|
println!("upload from path");
|
||||||
|
|
||||||
|
// println!("prefix: {:?}", prefix.unwrap_or(""));
|
||||||
|
|
||||||
let check_upload_res = self.client.check_upload(req).await.unwrap();
|
let check_upload_res = self.client.check_upload(req).await.unwrap();
|
||||||
|
|
||||||
@ -238,7 +256,7 @@ impl RakutenDriveClient {
|
|||||||
multipart_upload_from_path(
|
multipart_upload_from_path(
|
||||||
&token_res,
|
&token_res,
|
||||||
&check_upload_res.bucket,
|
&check_upload_res.bucket,
|
||||||
&check_upload_res.file[1],
|
&check_upload_res.file[0],
|
||||||
&check_upload_res.prefix,
|
&check_upload_res.prefix,
|
||||||
&check_upload_res.region,
|
&check_upload_res.region,
|
||||||
&check_upload_res.upload_id,
|
&check_upload_res.upload_id,
|
||||||
|
@ -169,6 +169,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
return Err(anyhow::anyhow!("Prefix must end with /"));
|
return Err(anyhow::anyhow!("Prefix must end with /"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("is_dir: {}", file.is_dir());
|
||||||
if file.is_dir() {
|
if file.is_dir() {
|
||||||
println!("name: {:?}", file.file_name().unwrap().to_str().unwrap());
|
println!("name: {:?}", file.file_name().unwrap().to_str().unwrap());
|
||||||
println!("prefix: {:?}", prefix.as_deref());
|
println!("prefix: {:?}", prefix.as_deref());
|
||||||
@ -331,6 +332,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
// println!("prefix: {:?}", file_dir);
|
// println!("prefix: {:?}", file_dir);
|
||||||
|
|
||||||
if stream {
|
if stream {
|
||||||
|
println!("is stream true");
|
||||||
client
|
client
|
||||||
.upload_from_path(file.clone(), Some(&file_dir), fake_size, Some(pb))
|
.upload_from_path(file.clone(), Some(&file_dir), fake_size, Some(pb))
|
||||||
.await
|
.await
|
||||||
|
@ -76,7 +76,7 @@ pub struct CheckUploadRequest {
|
|||||||
pub file: Vec<CheckUploadRequestFile>,
|
pub file: Vec<CheckUploadRequestFile>,
|
||||||
pub host_id: String,
|
pub host_id: String,
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub upload_id: String,
|
// pub upload_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -84,6 +84,9 @@ pub struct CheckUploadRequest {
|
|||||||
pub struct CheckUploadRequestFile {
|
pub struct CheckUploadRequestFile {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub size: i64,
|
pub size: i64,
|
||||||
|
pub hash: Option<bool>, // always null
|
||||||
|
pub version_id: Option<bool>, // always null
|
||||||
|
pub host_id: Option<bool>, // always null
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -100,6 +103,9 @@ pub struct CompleteUploadRequest {
|
|||||||
pub struct CompleteUploadRequestFile {
|
pub struct CompleteUploadRequestFile {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub size: i64,
|
pub size: i64,
|
||||||
|
pub hash: Option<bool>, // always null
|
||||||
|
pub version_id: Option<bool>, // always null
|
||||||
|
pub host_id: Option<bool>, // always null
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
@ -158,4 +164,5 @@ pub struct CopyFileRequestFile {
|
|||||||
pub struct VerifyCustomTokenRequest {
|
pub struct VerifyCustomTokenRequest {
|
||||||
pub return_secure_token: bool,
|
pub return_secure_token: bool,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,6 +446,7 @@ pub async fn list_files(
|
|||||||
thumbnail_size: 130,
|
thumbnail_size: 130,
|
||||||
to: pagination_size,
|
to: pagination_size,
|
||||||
};
|
};
|
||||||
|
println!("{:#?}", req);
|
||||||
let mut res = client.list_files(req).await?;
|
let mut res = client.list_files(req).await?;
|
||||||
|
|
||||||
files.append(&mut res.file);
|
files.append(&mut res.file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user