feat: secfile

This commit is contained in:
2023-03-05 18:00:57 +08:00
parent 8dda36da48
commit d874cbd0a4

View File

@@ -16,7 +16,7 @@ use std::path::PathBuf;
use base64::Engine;
use clap::{arg, Parser};
use rust_util::{debugging, failure_and_exit, information, success};
use rust_util::{debugging, failure_and_exit, information, success, warning, util_size};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None, bin_name = "post.rs")]
@@ -77,6 +77,11 @@ fn main() {
let file_bytes = fs::read(&file).unwrap_or_else(|e| {
failure_and_exit!("Read file: {:?} failed: {}", file, e)
});
if file_bytes.len() > 10 * 1024 * 1024 {
warning!("File: {:?} is large, size: {}", file, util_size::get_display_size(file_bytes.len() as i64));
} else {
information!("File: {:?} size: {}", file, util_size::get_display_size(file_bytes.len() as i64));
}
base64::engine::general_purpose::STANDARD.encode(&file_bytes)
};