pub struct SimpleUploadOptions {
pub chunk_size: usize,
pub max_concurrency: usize,
pub type: i32,
}Expand description
Options for simple upload methods
Use the builder pattern to customize upload behavior:
§Example
use baidu_netdisk_sdk::upload::SimpleUploadOptions;
let options = SimpleUploadOptions::default()
.chunk_size(8 * 1024 * 1024) // 8MB chunks
.max_concurrency(20) // 20 parallel uploads
.r#type(1); // file type§Default Values
chunk_size: 4MB (4194304 bytes)max_concurrency: 10r#type: 1
Fields§
§chunk_size: usizeSize of each chunk in bytes (default: 4MB)
max_concurrency: usizeMaximum number of parallel chunk uploads (default: 10)
type: i32File type hint (default: 1)
Implementations§
Source§impl SimpleUploadOptions
impl SimpleUploadOptions
pub fn new() -> Self
Sourcepub fn chunk_size(self, size: usize) -> Self
pub fn chunk_size(self, size: usize) -> Self
Examples found in repository?
examples/upload_file_options.rs (line 38)
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 env_logger::init();
8
9 let client = BaiduNetDiskClient::builder().build()?;
10 info!("Client created successfully");
11
12 client.load_token_from_env()?;
13 info!("Token loaded successfully");
14
15 let args: Vec<String> = std::env::args().collect();
16
17 if args.len() < 3 {
18 println!(
19 "Usage: {} <local_file> <remote_path> [chunk_size] [concurrency]",
20 args[0]
21 );
22 println!("Example: {} test.mp4 /upload/video.mp4 8388608 20", args[0]);
23 println!(" - chunk_size: bytes per chunk (default: 4194304 = 4MB)");
24 println!(" - concurrency: parallel uploads (default: 10)");
25 return Ok(());
26 }
27
28 let local_file = &args[1];
29 let remote_path = &args[2];
30
31 let chunk_size: usize = args
32 .get(3)
33 .and_then(|s| s.parse().ok())
34 .unwrap_or(4 * 1024 * 1024);
35 let concurrency: usize = args.get(4).and_then(|s| s.parse().ok()).unwrap_or(10);
36
37 let options = SimpleUploadOptions::default()
38 .chunk_size(chunk_size)
39 .max_concurrency(concurrency);
40
41 println!("=== Baidu NetDisk File Upload (Custom Options) ===");
42 println!("Local file: {}", local_file);
43 println!("Remote path: {}", remote_path);
44 println!(
45 "Chunk size: {} bytes ({:.2} MB)",
46 chunk_size,
47 chunk_size as f64 / 1024.0 / 1024.0
48 );
49 println!("Concurrency: {}", concurrency);
50 println!();
51
52 let start_time = std::time::Instant::now();
53
54 let response = client
55 .upload()
56 .upload_file_with_options(local_file, remote_path, options)
57 .await?;
58
59 println!("File uploaded successfully!");
60 println!(" FS ID: {}", response.fs_id);
61 println!(" Path: {}", response.path);
62 println!(" Size: {} bytes", response.size);
63 println!(" Category: {}", response.category);
64 println!(" MD5: {}", response.md5.unwrap_or_default());
65 println!(" Upload time: {:?}", start_time.elapsed());
66
67 Ok(())
68}Sourcepub fn max_concurrency(self, concurrency: usize) -> Self
pub fn max_concurrency(self, concurrency: usize) -> Self
Examples found in repository?
examples/upload_file_options.rs (line 39)
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 env_logger::init();
8
9 let client = BaiduNetDiskClient::builder().build()?;
10 info!("Client created successfully");
11
12 client.load_token_from_env()?;
13 info!("Token loaded successfully");
14
15 let args: Vec<String> = std::env::args().collect();
16
17 if args.len() < 3 {
18 println!(
19 "Usage: {} <local_file> <remote_path> [chunk_size] [concurrency]",
20 args[0]
21 );
22 println!("Example: {} test.mp4 /upload/video.mp4 8388608 20", args[0]);
23 println!(" - chunk_size: bytes per chunk (default: 4194304 = 4MB)");
24 println!(" - concurrency: parallel uploads (default: 10)");
25 return Ok(());
26 }
27
28 let local_file = &args[1];
29 let remote_path = &args[2];
30
31 let chunk_size: usize = args
32 .get(3)
33 .and_then(|s| s.parse().ok())
34 .unwrap_or(4 * 1024 * 1024);
35 let concurrency: usize = args.get(4).and_then(|s| s.parse().ok()).unwrap_or(10);
36
37 let options = SimpleUploadOptions::default()
38 .chunk_size(chunk_size)
39 .max_concurrency(concurrency);
40
41 println!("=== Baidu NetDisk File Upload (Custom Options) ===");
42 println!("Local file: {}", local_file);
43 println!("Remote path: {}", remote_path);
44 println!(
45 "Chunk size: {} bytes ({:.2} MB)",
46 chunk_size,
47 chunk_size as f64 / 1024.0 / 1024.0
48 );
49 println!("Concurrency: {}", concurrency);
50 println!();
51
52 let start_time = std::time::Instant::now();
53
54 let response = client
55 .upload()
56 .upload_file_with_options(local_file, remote_path, options)
57 .await?;
58
59 println!("File uploaded successfully!");
60 println!(" FS ID: {}", response.fs_id);
61 println!(" Path: {}", response.path);
62 println!(" Size: {} bytes", response.size);
63 println!(" Category: {}", response.category);
64 println!(" MD5: {}", response.md5.unwrap_or_default());
65 println!(" Upload time: {:?}", start_time.elapsed());
66
67 Ok(())
68}pub fn type(self, type: i32) -> Self
Trait Implementations§
Source§impl Clone for SimpleUploadOptions
impl Clone for SimpleUploadOptions
Source§fn clone(&self) -> SimpleUploadOptions
fn clone(&self) -> SimpleUploadOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SimpleUploadOptions
impl Debug for SimpleUploadOptions
Auto Trait Implementations§
impl Freeze for SimpleUploadOptions
impl RefUnwindSafe for SimpleUploadOptions
impl Send for SimpleUploadOptions
impl Sync for SimpleUploadOptions
impl Unpin for SimpleUploadOptions
impl UnsafeUnpin for SimpleUploadOptions
impl UnwindSafe for SimpleUploadOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more