ability to read non utf-8 files as attachments

This commit is contained in:
winwinner 2023-11-30 17:26:41 +00:00
parent bc64746424
commit 1be8ca20a6
Signed by: winneratwin
GPG Key ID: F11B4D71AD94CFB8

View File

@ -91,9 +91,9 @@ fn create_paste(cfg: Cli, input: String) -> String {
// check if attachment exists
if cfg.attachment.is_some() {
// read file
let file_contents = std::fs::read_to_string(cfg.attachment.unwrap()).unwrap();
let file_contents = std::fs::read(cfg.attachment.unwrap()).unwrap();
// encode file contents as data URI
let data_uri = format!("data:application/octet-stream;base64,{}", b64.encode(file_contents.as_bytes()));
let data_uri = format!("data:application/octet-stream;base64,{}", b64.encode(file_contents));
paste_data.attachment = Some(data_uri);
if cfg.filename.is_some() {