()
| 31 | ) |
| 32 | |
| 33 | func main() { |
| 34 | // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname, my-objectname and |
| 35 | // my-testfile are dummy values, please replace them with original values. |
| 36 | |
| 37 | // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access. |
| 38 | // This boolean value is the last argument for New(). |
| 39 | |
| 40 | // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically |
| 41 | // determined based on the Endpoint value. |
| 42 | s3Client, err := minio.New("s3.amazonaws.com", &minio.Options{ |
| 43 | Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""), |
| 44 | Secure: true, |
| 45 | }) |
| 46 | if err != nil { |
| 47 | log.Fatalln(err) |
| 48 | } |
| 49 | |
| 50 | opts := minio.SelectObjectOptions{ |
| 51 | Expression: "select count(*) from s3object", |
| 52 | ExpressionType: minio.QueryExpressionTypeSQL, |
| 53 | InputSerialization: minio.SelectObjectInputSerialization{ |
| 54 | CompressionType: minio.SelectCompressionNONE, |
| 55 | CSV: &minio.CSVInputOptions{ |
| 56 | FileHeaderInfo: minio.CSVFileHeaderInfoNone, |
| 57 | RecordDelimiter: "\n", |
| 58 | FieldDelimiter: ",", |
| 59 | }, |
| 60 | }, |
| 61 | OutputSerialization: minio.SelectObjectOutputSerialization{ |
| 62 | CSV: &minio.CSVOutputOptions{ |
| 63 | RecordDelimiter: "\n", |
| 64 | FieldDelimiter: ",", |
| 65 | }, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | reader, err := s3Client.SelectObjectContent(context.Background(), "mycsvbucket", "mycsv.csv", opts) |
| 70 | if err != nil { |
| 71 | log.Fatalln(err) |
| 72 | } |
| 73 | defer reader.Close() |
| 74 | |
| 75 | if _, err := io.Copy(os.Stdout, reader); err != nil { |
| 76 | log.Fatalln(err) |
| 77 | } |
| 78 | } |
nothing calls this directly
no test coverage detected