feat(bridge,ui): preserve file names and use system opener

- Add mattermost-download-dir custom (default ~/Downloads)
- Pass file_name and download_dir in download_file request
- Save files with original names in user-configured directory
- Open downloaded files via xdg-open (system default application)
This commit is contained in:
Ivan I. Ovchinnikov
2026-11-21 14:03:22 +03:00
parent d05a3a180e
commit d33edb4e44
5 changed files with 142 additions and 4 deletions
+19
View File
@@ -294,6 +294,25 @@ impl MattermostClient {
let post: Post = response.json().await.map_err(ClientError::Http)?;
Ok(post)
}
/// Download a file by its ID. Returns the file bytes.
pub async fn download_file(&self, token: &str, file_id: &str) -> Result<Vec<u8>, ClientError> {
let url = format!("{}/api/v4/files/{}", self.base_url, file_id);
let response = self
.client
.get(&url)
.header(AUTHORIZATION, format!("Bearer {}", token))
.send()
.await
.map_err(ClientError::Http)?;
if !response.status().is_success() {
return Err(api_error(response).await);
}
let bytes = response.bytes().await.map_err(ClientError::Http)?;
Ok(bytes.to_vec())
}
}
/// Accept `[fileinfo, ...]`, `{file_infos: [...]}`, or