put media in filesystem

This commit is contained in:
hamidreza kalbasi 2021-06-04 08:06:12 +04:30 committed by Timo Kösters
parent d0ee823254
commit 972caacdc2
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
6 changed files with 78 additions and 30 deletions

View file

@ -5,11 +5,7 @@ use ruma::{
EventId, MilliSecondsSinceUnixEpoch, ServerName, ServerSigningKeyId,
};
use rustls::{ServerCertVerifier, WebPKIVerifier};
use std::{
collections::{BTreeMap, HashMap},
sync::{Arc, RwLock},
time::{Duration, Instant},
};
use std::{collections::{BTreeMap, HashMap}, path::{PathBuf}, sync::{Arc, RwLock}, time::{Duration, Instant}};
use tokio::sync::Semaphore;
use trust_dns_resolver::TokioAsyncResolver;
@ -275,4 +271,19 @@ impl Globals {
.insert(b"version", &new_version.to_be_bytes())?;
Ok(())
}
pub fn get_media_folder(&self) -> PathBuf {
let mut r = PathBuf::new();
r.push(self.config.database_path.clone());
r.push("media");
r
}
pub fn get_media_file(&self, key: &Vec<u8>) -> PathBuf {
let mut r = PathBuf::new();
r.push(self.config.database_path.clone());
r.push("media");
r.push(base64::encode_config(key, base64::URL_SAFE_NO_PAD));
r
}
}