Last active
April 19, 2017 11:54
-
-
Save krisis/c9a2c8cdf695b53cb538ad44bfc943a7 to your computer and use it in GitHub Desktop.
PutObjectStreaming example
This file contains 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 ( | |
"flag" | |
"log" | |
"os" | |
minio "github.com/minio/minio-go" | |
) | |
func main() { | |
var object, bucket, accessKey, secretKey string | |
location := "us-east-1" | |
flag.StringVar(&bucket, "b", "stream-test", "Bucket name") | |
flag.StringVar(&object, "o", "stream-test", "Object key name") | |
flag.StringVar(&accessKey, "a", "", "accessKey") | |
flag.StringVar(&secretKey, "s", "", "secretKey") | |
flag.Parse() | |
client, err := minio.NewWithRegion("localhost:9000", accessKey, secretKey, false, "us-east-1") | |
// Test if bucket is there | |
exists, _ := client.BucketExists(bucket) | |
if !exists { | |
// Try to create bucket | |
err = client.MakeBucket(bucket, location) | |
} | |
n, err := client.PutObjectStreaming(bucket, object, os.Stdin, 5000000000) | |
if err != nil { | |
log.Fatal(err) | |
return | |
} | |
log.Printf("Written %d bytes to %s in bucket %s.", n, object, bucket) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment