create get_file_media_info
This commit is contained in:
parent
2fa9b3f32b
commit
e795177d27
1 changed files with 14 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue