feat(cli): insert entities for files with =, urls
This commit is contained in:
parent
6061ffb858
commit
49cf2a5506
1 changed files with 14 additions and 0 deletions
|
@ -10,6 +10,7 @@ use rand::{thread_rng, Rng};
|
|||
use reqwest::Url;
|
||||
use serde_json::json;
|
||||
use std::net::SocketAddr;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tracing::trace;
|
||||
|
@ -204,6 +205,19 @@ fn main() -> Result<()> {
|
|||
return Err(anyhow!("Invalid entry value."));
|
||||
}
|
||||
|
||||
let entity = match entity {
|
||||
entity if entity.starts_with('=') => {
|
||||
let filepath = Path::new(&entity[1..]);
|
||||
debug!("Hashing {:?}...", filepath);
|
||||
let fbuffer = FileBuffer::open(&filepath)?;
|
||||
let digest = hash(&fbuffer);
|
||||
trace!("Finished hashing {:?}...", &filepath);
|
||||
Address::Hash(digest).to_string()
|
||||
}
|
||||
entity if entity.starts_with("http") => Address::Url(entity).to_string(),
|
||||
_ => entity,
|
||||
};
|
||||
|
||||
let body = json!({
|
||||
"entity": entity,
|
||||
"attribute": attribute,
|
||||
|
|
Loading…
Reference in a new issue