Download Active Response (#49)

This PR prompts you to save un-previewable file types and adds an option
to save to the response history.
This commit is contained in:
Gregory Schier
2024-06-10 16:36:09 -07:00
committed by GitHub
parent 3875f90fea
commit f0c7a83134
14 changed files with 190 additions and 35 deletions

View File

@@ -958,6 +958,28 @@ async fn cmd_export_data(
Ok(())
}
#[tauri::command]
async fn cmd_save_response(
window: WebviewWindow,
response_id: &str,
filepath: &str,
) -> Result<(), String> {
let response = get_http_response(&window, response_id)
.await
.map_err(|e| e.to_string())?;
let body_path = match response.body_path {
None => {
return Err("Response does not have a body".to_string());
}
Some(p) => p,
};
fs::copy(body_path, filepath).map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
async fn cmd_send_http_request(
window: WebviewWindow,
@@ -1702,6 +1724,7 @@ pub fn run() {
cmd_new_window,
cmd_request_to_curl,
cmd_dismiss_notification,
cmd_save_response,
cmd_send_ephemeral_request,
cmd_send_http_request,
cmd_set_key_value,