ability to read non utf-8 files as attachments
This commit is contained in:
parent
bc64746424
commit
1be8ca20a6
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user