Last active
June 23, 2017 10:21
-
-
Save grodowski/41a0c4f4db6ad18718e5725f655389b6 to your computer and use it in GitHub Desktop.
Minio upload empty byte array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"log" | |
"github.com/grodowski/minio-go" | |
) | |
func main() { | |
endpoint := "localhost:9000" | |
accessKey := "bacon" | |
secretKey := "bacon123" | |
useSSL := false | |
minioClient, err := minio.New(endpoint, accessKey, secretKey, useSSL) | |
if err != nil { | |
fmt.Println(err) | |
} | |
bucketName := "burnafterreading" | |
exists, err := minioClient.BucketExists(bucketName) | |
if err != nil { | |
log.Fatalf("error querying for bucket %q existence: %v", bucketName, err) | |
} | |
if !exists { | |
if err := minioClient.MakeBucket(bucketName, "us-east-1"); err != nil { | |
log.Fatalf("error creating bucket %q: %v", bucketName, err) | |
} | |
} | |
objectName := "test003.bin" | |
reader := bytes.NewReader(make([]byte, 0)) | |
contentType := "application/octet-stream" | |
_, err = minioClient.PutObject(bucketName, objectName, reader, contentType) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println("Finished") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment