MCPcopy
hub / github.com/minio/minio-go / main

Function main

examples/s3/listobjectversions.go:31–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29)
30
31func main() {
32 // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-prefixname
33 // are dummy values, please replace them with original values.
34
35 // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
36 // This boolean value is the last argument for New().
37
38 // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
39 // determined based on the Endpoint value.
40 s3Client, err := minio.New("s3.amazonaws.com", &minio.Options{
41 Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""),
42 Secure: true,
43 })
44 if err != nil {
45 fmt.Println(err)
46 return
47 }
48
49 opts := minio.ListObjectsOptions{
50 WithVersions: true,
51 Prefix: "my-prefixname",
52 Recursive: true,
53 }
54
55 // List all objects from a bucket-name with a matching prefix.
56 for objectVersion := range s3Client.ListObjects(context.Background(), "my-bucketname", opts) {
57 if objectVersion.Err != nil {
58 fmt.Println(objectVersion.Err)
59 return
60 }
61 fmt.Println(objectVersion)
62 }
63 return
64}

Callers

nothing calls this directly

Calls 2

NewStaticV4Function · 0.92
ListObjectsMethod · 0.45

Tested by

no test coverage detected