SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "log"
  5.  
  6.     "github.com/minio/minio-go"
  7. )
  8.  
  9. func main() {
  10.     endpoint := "play.min.io:9000"
  11.     accessKeyID := "Q3AM3UQ867SPQQA43P2F"
  12.     secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
  13.     useSSL := true
  14.  
  15.     // Initialize minio client object.
  16.     minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
  17.     if err != nil {
  18.         log.Fatalln(err)
  19.     }
  20.  
  21.     // Make a new bucket called mymusic.
  22.     bucketNames := []string{"my_bucket", "my"}
  23.     location := "us-east-1"
  24.  
  25.     for _, testBucketName := range bucketNames {
  26.         err = minioClient.MakeBucket(testBucketName, location)
  27.         if err != nil {
  28.             // Check to see if we already own this bucket (which happens if you run this twice)
  29.             exists, err2 := minioClient.BucketExists(testBucketName)
  30.             if err == nil && exists {
  31.                 log.Printf("We already own %s\n", testBucketName)
  32.             } else {
  33.                 log.Printf("MakeBucket error: %v, BucketExists error: %v\n", err, err2)
  34.             }
  35.         } else {
  36.             log.Printf("Successfully created %s\n", testBucketName)
  37.         }
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top