| 21 | } |
| 22 | |
| 23 | pub fn upload_s3_file(archive: Option<&Archive>, file_path: &Path) -> Result<(), anyhow::Error> { |
| 24 | let archive = match archive { |
| 25 | Some(archive) => archive, |
| 26 | None => { |
| 27 | info!("no archive upload (request.archive is None)"); |
| 28 | return Ok(()); |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | info!( |
| 33 | "Sending file {} to bucket {}://{}{}", |
| 34 | file_path.to_str().unwrap_or_default(), |
| 35 | archive.upload_url.scheme(), |
| 36 | archive.upload_url.host_str().unwrap_or(""), |
| 37 | archive.upload_url.path() |
| 38 | ); |
| 39 | |
| 40 | let file = std::fs::File::open(file_path)?; |
| 41 | reqwest::blocking::Client::builder() |
| 42 | .connect_timeout(Duration::from_secs(30)) |
| 43 | .build()? |
| 44 | .put(archive.upload_url.clone()) |
| 45 | .header(CONTENT_TYPE, "application/octet-stream") |
| 46 | .body(file) |
| 47 | .timeout(Duration::from_secs(60 * 5)) |
| 48 | .send()? |
| 49 | .error_for_status()?; |
| 50 | |
| 51 | Ok(()) |
| 52 | } |
| 53 | |
| 54 | pub fn enable_log_file_writer(context: &Context, log_file_writer: &Option<LogFileWriter>) { |
| 55 | if let Some(log_file_writer) = &log_file_writer { |