Skip to content

Commit

Permalink
Add missing context value to example (#1373)
Browse files Browse the repository at this point in the history
`BucketExists` was missing a context value.

We place it in a variable to make the code cleaner.
  • Loading branch information
klauspost authored Aug 19, 2020
1 parent 23e4ee4 commit b1c297f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
log.Fatalln(err)
}

log.Printf("%#v\n", minioClient) // minioClient is now setup
log.Printf("%#v\n", minioClient) // minioClient is now set up
}
```

Expand All @@ -67,6 +67,7 @@ import (
)

func main() {
ctx := context.Background()
endpoint := "play.min.io"
accessKeyID := "Q3AM3UQ867SPQQA43P2F"
secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
Expand All @@ -85,10 +86,10 @@ func main() {
bucketName := "mymusic"
location := "us-east-1"

err = minioClient.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: location})
err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
if err != nil {
// Check to see if we already own this bucket (which happens if you run this twice)
exists, errBucketExists := minioClient.BucketExists(bucketName)
exists, errBucketExists := minioClient.BucketExists(ctx, bucketName)
if errBucketExists == nil && exists {
log.Printf("We already own %s\n", bucketName)
} else {
Expand All @@ -104,7 +105,7 @@ func main() {
contentType := "application/zip"

// Upload the zip file with FPutObject
n, err := minioClient.FPutObject(context.Background(), bucketName, objectName, filePath, minio.PutObjectOptions{ContentType: contentType})
n, err := minioClient.FPutObject(ctx, bucketName, objectName, filePath, minio.PutObjectOptions{ContentType: contentType})
if err != nil {
log.Fatalln(err)
}
Expand Down

0 comments on commit b1c297f

Please sign in to comment.