create get_file_media_info

This commit is contained in:
mairandomness 2019-02-25 14:41:41 -05:00
parent 2fa9b3f32b
commit e795177d27

View file

@ -276,6 +276,7 @@ impl AppOp {
let info = match mtype {
"m.image" => get_image_media_info(path_string, mime.as_ref()),
"m.audio" => get_audio_media_info(path_string, mime.as_ref()),
"m.file" => get_file_media_info(path_string, mime.as_ref()),
_ => None,
};
@ -540,3 +541,16 @@ fn get_audio_media_info(file: &str, mimetype: &str) -> Option<JsonValue> {
Some(info)
}
fn get_file_media_info(file: &str, mimetype: &str) -> Option<JsonValue> {
let size = fs::metadata(file).ok()?.len();
let info = json!({
"info": {
"size": size,
"mimetype": mimetype,
}
});
Some(info)
}