|
1 | 1 | use crate::command_utils::CommandOutput; |
2 | | -use minio::s3::builders::{ObjectContent, PutObjectContent}; |
| 2 | +use minio::s3::args::PutObjectArgs; |
| 3 | +use minio::s3::client::{Client, ClientBuilder}; |
3 | 4 | use minio::s3::creds::StaticProvider; |
4 | 5 | use minio::s3::http::BaseUrl; |
5 | | -use minio::s3::multimap::Multimap; |
6 | | -use minio::s3::{Client, ClientBuilder}; |
| 6 | +use minio::s3::utils::Multimap; |
7 | 7 | use serde::{Deserialize, Serialize}; |
8 | 8 | use std::env; |
| 9 | +use std::io::{Cursor, Read}; |
9 | 10 |
|
10 | 11 | #[derive(Serialize, Deserialize, Debug)] |
11 | 12 | struct Notification { |
@@ -74,19 +75,15 @@ async fn save_oss(notification: &Notification) -> anyhow::Result<()> { |
74 | 75 | if let Some(stderr) = ¬ification.stderr { |
75 | 76 | text.push_str(stderr); |
76 | 77 | } |
77 | | - let content = ObjectContent::from(text); |
78 | | - let mut put_object = PutObjectContent::new( |
79 | | - minio_client, |
80 | | - s3_bucket, |
81 | | - notification.task_id.clone(), |
82 | | - content, |
83 | | - ); |
84 | | - put_object = put_object.content_type("text/plain".to_string()); |
| 78 | + let reader: &mut dyn Read = &mut Cursor::new(text.as_bytes()); |
| 79 | + let mut put_object = |
| 80 | + PutObjectArgs::new(&s3_bucket, ¬ification.task_id, reader, None, None)?; |
| 81 | + put_object.content_type = "text/plain"; |
85 | 82 | let mut user_metadata = Multimap::new(); |
86 | 83 | user_metadata.insert("status".to_string(), notification.status.to_string()); |
87 | 84 | user_metadata.insert("command".to_string(), notification.command_name.to_string()); |
88 | | - put_object = put_object.user_metadata(Some(user_metadata)); |
89 | | - put_object.send().await?; |
| 85 | + put_object.user_metadata = Some(&user_metadata); |
| 86 | + minio_client.put_object(&mut put_object).await?; |
90 | 87 | } |
91 | 88 | Ok(()) |
92 | 89 | } |
|
0 commit comments