mirror of
https://github.com/Waradu/to-streamshare.git
synced 2025-04-22 04:14:06 +02:00
added download
This commit is contained in:
parent
27c765bce4
commit
a452ff1631
4 changed files with 50 additions and 19 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -1237,9 +1237,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
|||
|
||||
[[package]]
|
||||
name = "streamshare"
|
||||
version = "4.0.0"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d8642382451166982e9ca79fa523c65350c72b113b5c4a89887a1181a16ac44"
|
||||
checksum = "b1960eb9ada032cacbd7b75b1255468a007459729009b76e508579bd49d97171"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"reqwest",
|
||||
|
@ -1362,7 +1362,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||
|
||||
[[package]]
|
||||
name = "to-streamshare"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"console",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "to-streamshare"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
edition = "2021"
|
||||
description = "Upload to streamshare (to-ss > toss) from the terminal"
|
||||
license = "MIT"
|
||||
|
@ -14,7 +14,7 @@ keywords = ["streamshare", "file-sharing", "upload"]
|
|||
clap = { version = "4.5.20", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
kdam = { version = "0.5.2", features = ["rich", "spinner"] }
|
||||
streamshare = "4"
|
||||
streamshare = "4.1"
|
||||
tokio = { version = "1.40.0", features = ["full"] }
|
||||
|
||||
[[bin]]
|
||||
|
|
13
README.md
13
README.md
|
@ -12,12 +12,19 @@ cargo install to-streamshare
|
|||
|
||||
```bash
|
||||
toss "filepath"
|
||||
toss "filepath" --chunk-size 100 # set chunk_size to 100
|
||||
toss "filepath" --server "streamshare.myserver.com" # set server to your server
|
||||
toss --chunk-size 100 "filepath" # set chunk_size to 100
|
||||
toss --server "streamshare.myserver.com" "filepath" # set server to your server
|
||||
```
|
||||
|
||||
### Delete
|
||||
|
||||
```bash
|
||||
toss --delete file_identifier/deletion_token
|
||||
toss --delete "file_identifier/deletion_token"
|
||||
```
|
||||
|
||||
### Download
|
||||
|
||||
```bash
|
||||
toss --download "file_identifier"
|
||||
toss --download "file_identifier" --path "" # uses current path as default
|
||||
```
|
44
src/main.rs
44
src/main.rs
|
@ -13,19 +13,11 @@ use streamshare::StreamShare;
|
|||
struct Args {
|
||||
file: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
value_name = "DELETE",
|
||||
help = "Specify a file to delete in the format 'file_identifier/deletion_token' (e.g., 'abc123/def456')"
|
||||
)]
|
||||
delete: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
value_name = "SERVER",
|
||||
help = "Specify a server",
|
||||
help = "Specify a server.",
|
||||
default_value = "streamshare.wireway.ch"
|
||||
)]
|
||||
server: Option<String>,
|
||||
|
@ -33,11 +25,33 @@ struct Args {
|
|||
#[arg(
|
||||
short,
|
||||
long,
|
||||
value_name = "CHUNK-SIZE",
|
||||
value_name = "CHUNK_SIZE",
|
||||
help = "Specify a chunk size",
|
||||
default_value = "1048576"
|
||||
)]
|
||||
chunk_size: Option<String>,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
value_name = "DELETE",
|
||||
help = "Delete a file. Format: 'file_identifier/deletion_token'"
|
||||
)]
|
||||
delete: Option<String>,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
value_name = "DOWNLOAD",
|
||||
help = "Download a file. Format: 'file_identifier'"
|
||||
)]
|
||||
download: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
value_name = "PATH",
|
||||
help = "Set the path to download the file to."
|
||||
)]
|
||||
path: Option<String>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
@ -63,6 +77,16 @@ async fn main() -> std::io::Result<()> {
|
|||
} else {
|
||||
eprintln!("Invalid format for --delete. Use 'file_identifier/deletion_token' (e.g., 'abc123/def456')");
|
||||
}
|
||||
} else if let Some(download) = args.download {
|
||||
let path = match args.path {
|
||||
Some(p) => p,
|
||||
None => "".to_string()
|
||||
};
|
||||
|
||||
match client.download(download.as_str(), path.as_str()).await {
|
||||
Ok(_) => println!("File downloaded successfully"),
|
||||
Err(e) => eprintln!("Error downloaded file: {}", e),
|
||||
}
|
||||
} else if let Some(file_path) = args.file {
|
||||
kdam::term::init(stderr().is_terminal());
|
||||
kdam::term::hide_cursor()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue