Randomize names for personal profit
This commit is contained in:
parent
412cca7cde
commit
a300792578
3 changed files with 11 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -785,6 +785,7 @@ dependencies = [
|
|||
"futures-util",
|
||||
"log",
|
||||
"notify-rust",
|
||||
"rand",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
|||
|
|
@ -19,3 +19,4 @@ log = "0.4.22"
|
|||
notify-rust = "4.11.3"
|
||||
wl-clipboard-rs = "0.9.1"
|
||||
async-stream = "0.3.6"
|
||||
rand = "0.8.5"
|
||||
|
|
|
|||
12
src/main.rs
12
src/main.rs
|
|
@ -9,8 +9,10 @@ use std::sync::{Arc, Mutex};
|
|||
use clap::Parser;
|
||||
use futures_util::StreamExt;
|
||||
use notify_rust::{Hint, Notification, NotificationHandle};
|
||||
use rand::distributions::Alphanumeric;
|
||||
use reqwest::header::{HeaderValue, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use wl_clipboard_rs::copy::{ClipboardType, MimeType, Options, Source};
|
||||
use rand::{random, Rng};
|
||||
|
||||
type GodriveToken = String;
|
||||
|
||||
|
|
@ -218,13 +220,17 @@ async fn post_upload(
|
|||
match fs::metadata(file) {
|
||||
Ok(metadata) => {
|
||||
let content_length = metadata.len();
|
||||
let prefix: String = rand::thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(8)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
file_infos.push(GodriveUploadObj {
|
||||
name: file
|
||||
name: format!("{}-{}", prefix, file
|
||||
.file_name()
|
||||
.expect("You provided stupid file path")
|
||||
.to_str()
|
||||
.expect("You provided strange file path.")
|
||||
.to_string(),
|
||||
.expect("You provided strange file path.")),
|
||||
description: "".to_string(),
|
||||
overwrite: false,
|
||||
size: content_length,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue