handle CLI files
This commit is contained in:
parent
155487fa83
commit
9a1cabcb06
2 changed files with 20 additions and 11 deletions
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
|
@ -19,7 +19,11 @@
|
||||||
"kind": "bin"
|
"kind": "bin"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"args": [],
|
"args": [
|
||||||
|
"sharry.yavook.de",
|
||||||
|
"G7RYoWME1W7-pcgipemJcr8-39FcMd92gBu-RgufeHc51z6",
|
||||||
|
"/lib/x86_64-linux-gnu/liblldb-14.so.1",
|
||||||
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"RUST_LOG": "shrupl=debug",
|
"RUST_LOG": "shrupl=debug",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
25
src/main.rs
25
src/main.rs
|
|
@ -59,23 +59,28 @@ fn main() {
|
||||||
|
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
|
|
||||||
|
let files: Vec<File> = (args.files.iter())
|
||||||
|
.map(File::new)
|
||||||
|
.map(Result::unwrap)
|
||||||
|
.collect();
|
||||||
|
|
||||||
let alias = Alias::new(Uri::with_protocol(args.proto, args.url), args.alias);
|
let alias = Alias::new(Uri::with_protocol(args.proto, args.url), args.alias);
|
||||||
|
|
||||||
let share = NewShareRequest::new(args.name, args.desc, 10);
|
let share = NewShareRequest::new(args.name, args.desc, 10);
|
||||||
let share = Share::create(&agent, &alias, share).unwrap();
|
let share = Share::create(&agent, &alias, share).unwrap();
|
||||||
info!("share: {share:?}");
|
info!("share: {share:?}");
|
||||||
|
|
||||||
let file = File::new("/lib/x86_64-linux-gnu/liblldb-14.so.1")
|
for file in files {
|
||||||
.unwrap()
|
let file = file.create(&agent, &share).unwrap();
|
||||||
.create(&agent, &share)
|
info!("file: {file:?}");
|
||||||
.unwrap();
|
|
||||||
info!("file: {file:?}");
|
|
||||||
|
|
||||||
for chunk in file.chunked(args.chunk * 1024 * 1024) {
|
for chunk in file.chunked(args.chunk * 1024 * 1024) {
|
||||||
println!("chunk len: {}", chunk.bytes.len());
|
info!("chunk len: {}", chunk.bytes.len());
|
||||||
file.upload_chunk(&agent, &alias, &chunk)
|
|
||||||
.inspect_err(|e| error!("error: {e}"))
|
file.upload_chunk(&agent, &alias, &chunk)
|
||||||
.unwrap();
|
.inspect_err(|e| error!("error: {e}"))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
share.notify(&agent).unwrap();
|
share.notify(&agent).unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue