Skip to content

Instantly share code, notes, and snippets.

@fd0
Created January 3, 2016 17:21
Show Gist options
  • Save fd0/f852268fe0862fca81b3 to your computer and use it in GitHub Desktop.
Save fd0/f852268fe0862fca81b3 to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"fmt"
"io"
"log"
"os"
crand "crypto/rand"
"github.com/minio/minio-go"
)
const bucket = "restic-test-ffm"
const path = "testfile"
func main() {
client, err := minio.New("s3.amazonaws.com", os.Getenv("AWS_ACCESS_KEY_ID"), os.Getenv("AWS_SECRET_ACCESS_KEY"), false)
if err != nil {
log.Fatal(err)
}
client.TraceOn(os.Stderr)
// generate data
buf := bytes.NewBuffer(nil)
io.CopyN(buf, crand.Reader, 1<<23)
// save the data
n, err := client.PutObject(bucket, path, buf, int64(buf.Len()), "binary/octet-stream")
fmt.Printf("n %v, err %#v\n",n, err)
if err != nil {
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment