diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..a92f3a2 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/client.rs b/src/client.rs index 0a52011..d04fb3a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -89,7 +89,7 @@ impl Client { let request = client .get(format!( "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); diff --git a/src/lib.rs b/src/lib.rs index e19e767..d466328 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,20 +52,29 @@ impl RakutenDriveClient { fake_size: Option, pb: Option, ) -> anyhow::Result<()> { + let prefix = if prefix.unwrap_or("") == "/" { + "" + } else { + prefix.unwrap_or("") + }; let req = types::request::CheckUploadRequest { host_id: self.client.host_id.clone(), - path: prefix.unwrap_or("").to_string(), - upload_id: "".to_string(), + path: prefix.to_string(), file: files .iter() .map(|file| types::request::CheckUploadRequestFile { path: file.path.clone(), size: fake_size.unwrap_or(file.data.len() as u64) as i64, + version_id: None, + host_id: None, + hash: None, }) .collect(), }; - println!("prefix: {:?}", prefix.unwrap_or("")); + println!("{:#?}", req); + + // println!("prefix: {:?}", prefix.unwrap_or("")); let check_upload_res = self.client.check_upload(req).await.unwrap(); @@ -202,17 +211,26 @@ impl RakutenDriveClient { fake_size: Option, pb: Option, ) -> anyhow::Result<()> { + let prefix = if prefix.unwrap_or("") == "/" { + "" + } else { + prefix.unwrap_or("") + }; let req = types::request::CheckUploadRequest { host_id: self.client.host_id.clone(), - path: prefix.unwrap_or("").to_string(), - upload_id: "".to_string(), + path: prefix.to_string(), file: vec![types::request::CheckUploadRequestFile { path: file.file.to_str().unwrap().to_string(), 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(); @@ -238,7 +256,7 @@ impl RakutenDriveClient { multipart_upload_from_path( &token_res, &check_upload_res.bucket, - &check_upload_res.file[1], + &check_upload_res.file[0], &check_upload_res.prefix, &check_upload_res.region, &check_upload_res.upload_id, diff --git a/src/main.rs b/src/main.rs index b48fd18..d782325 100644 --- a/src/main.rs +++ b/src/main.rs @@ -169,6 +169,7 @@ async fn main() -> anyhow::Result<()> { return Err(anyhow::anyhow!("Prefix must end with /")); } } + println!("is_dir: {}", file.is_dir()); if file.is_dir() { println!("name: {:?}", file.file_name().unwrap().to_str().unwrap()); println!("prefix: {:?}", prefix.as_deref()); @@ -331,6 +332,7 @@ async fn main() -> anyhow::Result<()> { // println!("prefix: {:?}", file_dir); if stream { + println!("is stream true"); client .upload_from_path(file.clone(), Some(&file_dir), fake_size, Some(pb)) .await diff --git a/src/types/request.rs b/src/types/request.rs index ffbec9c..ef600ab 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -76,7 +76,7 @@ pub struct CheckUploadRequest { pub file: Vec, pub host_id: String, pub path: String, - pub upload_id: String, + // pub upload_id: String, } #[derive(Debug, Serialize, Deserialize)] @@ -84,6 +84,9 @@ pub struct CheckUploadRequest { pub struct CheckUploadRequestFile { pub path: String, pub size: i64, + pub hash: Option, // always null + pub version_id: Option, // always null + pub host_id: Option, // always null } #[derive(Debug, Serialize, Deserialize)] @@ -100,6 +103,9 @@ pub struct CompleteUploadRequest { pub struct CompleteUploadRequestFile { pub path: String, pub size: i64, + pub hash: Option, // always null + pub version_id: Option, // always null + pub host_id: Option, // always null } #[derive(Debug, Serialize, Deserialize)] @@ -158,4 +164,5 @@ pub struct CopyFileRequestFile { pub struct VerifyCustomTokenRequest { pub return_secure_token: bool, pub token: String, -} \ No newline at end of file +} + diff --git a/src/util.rs b/src/util.rs index 0b3a33f..0048131 100644 --- a/src/util.rs +++ b/src/util.rs @@ -446,6 +446,7 @@ pub async fn list_files( thumbnail_size: 130, to: pagination_size, }; + println!("{:#?}", req); let mut res = client.list_files(req).await?; files.append(&mut res.file);