diff --git a/Cargo.lock b/Cargo.lock index efbeec1..2be29c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,6 +54,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + [[package]] name = "bytes" version = "1.7.2" @@ -580,6 +589,7 @@ name = "upldis" version = "0.1.0" dependencies = [ "blake3", + "bs58", "fastly", "humanize-bytes", "humantime", diff --git a/Cargo.toml b/Cargo.toml index dffd15f..1ca0840 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,6 @@ tinytemplate = "1.2" serde_json = "1.0" humanize-bytes = "1.0" humantime = "2.1" +bs58 = "0.5" blake3 = "1.5" + diff --git a/src/main.rs b/src/main.rs index aa73e97..ab6d265 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,7 +134,7 @@ fn handle_put(mut req: Request) -> Result { let filename = url.path_segments().unwrap().last(); // Hash content and use it for the id - let hash = blake3::hash(&body).to_hex(); + let hash = bs58::encode(blake3::hash(&body).as_bytes()).into_string(); let id = &hash[..ID_LENGTH]; let kv = fastly::kv_store::KVStore::open(KV_STORE)?.expect("kv store to exist");