|
16 | 16 | use chrono::{DateTime, Utc}; |
17 | 17 | use minio::s3::builders::PostPolicy; |
18 | 18 | use minio::s3::types::{ |
19 | | - AndOperator, Destination, Filter, LifecycleConfig, LifecycleRule, NotificationConfig, |
20 | | - ObjectLockConfig, PrefixFilterRule, QueueConfig, ReplicationConfig, ReplicationRule, |
21 | | - RetentionMode, SuffixFilterRule, |
| 19 | + AndOperator, CsvInputSerialization, CsvOutputSerialization, Destination, FileHeaderInfo, |
| 20 | + Filter, LifecycleConfig, LifecycleRule, NotificationConfig, ObjectLockConfig, PrefixFilterRule, |
| 21 | + QueueConfig, QuoteFields, ReplicationConfig, ReplicationRule, RetentionMode, SelectRequest, |
| 22 | + SuffixFilterRule, |
22 | 23 | }; |
23 | 24 | use minio::s3::utils::utc_now; |
24 | 25 | use std::collections::HashMap; |
@@ -195,3 +196,38 @@ pub fn create_post_policy_example(bucket_name: &str, object_name: &str) -> PostP |
195 | 196 | .unwrap(); |
196 | 197 | policy |
197 | 198 | } |
| 199 | +/// return (body, data) |
| 200 | +pub fn create_select_content_data() -> (String, String) { |
| 201 | + let mut data = String::new(); |
| 202 | + data.push_str("1997,Ford,E350,\"ac, abs, moon\",3000.00\n"); |
| 203 | + data.push_str("1999,Chevy,\"Venture \"\"Extended Edition\"\"\",,4900.00\n"); |
| 204 | + data.push_str("1999,Chevy,\"Venture \"\"Extended Edition, Very Large\"\"\",,5000.00\n"); |
| 205 | + data.push_str("1996,Jeep,Grand Cherokee,\"MUST SELL!\n"); |
| 206 | + data.push_str("air, moon roof, loaded\",4799.00\n"); |
| 207 | + let body = String::from("Year,Make,Model,Description,Price\n") + &data; |
| 208 | + (body, data) |
| 209 | +} |
| 210 | +pub fn create_select_content_request() -> SelectRequest { |
| 211 | + let request = SelectRequest::new_csv_input_output( |
| 212 | + "select * from S3Object", |
| 213 | + CsvInputSerialization { |
| 214 | + compression_type: None, |
| 215 | + allow_quoted_record_delimiter: false, |
| 216 | + comments: None, |
| 217 | + field_delimiter: None, |
| 218 | + file_header_info: Some(FileHeaderInfo::USE), |
| 219 | + quote_character: None, |
| 220 | + quote_escape_character: None, |
| 221 | + record_delimiter: None, |
| 222 | + }, |
| 223 | + CsvOutputSerialization { |
| 224 | + field_delimiter: None, |
| 225 | + quote_character: None, |
| 226 | + quote_escape_character: None, |
| 227 | + quote_fields: Some(QuoteFields::ASNEEDED), |
| 228 | + record_delimiter: None, |
| 229 | + }, |
| 230 | + ) |
| 231 | + .unwrap(); |
| 232 | + request |
| 233 | +} |
0 commit comments