MCPcopy
hub / github.com/minio/minio-go / main

Function main

examples/minio/putobjectsnowball.go:36–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34)
35
36func main() {
37 const (
38 // Note: These constants are dummy values,
39 // please replace them with values for your setup.
40 YOURACCESSKEYID = "Q3AM3UQ867SPQQA43P2F"
41 YOURSECRETACCESSKEY = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
42 YOURENDPOINT = "play.min.io"
43 YOURBUCKET = "mybucket" // 'mc mb play/mybucket' if it does not exist.
44 )
45
46 // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
47 // This boolean value is the last argument for New().
48
49 // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
50 // determined based on the Endpoint value.
51 minioClient, err := minio.New(YOURENDPOINT, &minio.Options{
52 Creds: credentials.NewStaticV4(YOURACCESSKEYID, YOURSECRETACCESSKEY, ""),
53 Secure: true,
54 })
55 if err != nil {
56 log.Fatalln(err)
57 }
58 minioClient.TraceOn(os.Stdout)
59
60 input := make(chan minio.SnowballObject, 1)
61 opts := minio.SnowballOptions{
62 Opts: minio.PutObjectOptions{},
63 // Keep in memory. We use this since we have small total payload.
64 InMemory: true,
65 // Compress data when uploading to a MinIO host.
66 Compress: true,
67 }
68
69 // Generate a shared prefix.
70 rng := rand.New(rand.NewSource(time.Now().UnixNano()))
71 prefix := []byte("aaaaaaaaaaaaaaa")
72 for i := range prefix {
73 prefix[i] += byte(rng.Intn(25))
74 }
75
76 // Generate
77 go func() {
78 defer close(input)
79
80 // Create 100 objects
81 for i := 0; i < 100; i++ {
82 // With random size 0 -> 10000
83 size := rng.Intn(10000)
84 key := fmt.Sprintf("%s/%d-%d.bin", string(prefix), i, size)
85 input <- minio.SnowballObject{
86 // Create path to store objects within the bucket.
87 Key: key,
88 Size: int64(size),
89 ModTime: time.Now(),
90 Content: bytes.NewBuffer(make([]byte, size)),
91 Close: func() {
92 fmt.Println(key, "Close function called")
93 },

Callers

nothing calls this directly

Calls 4

NewStaticV4Function · 0.92
TraceOnMethod · 0.80
PutObjectsSnowballMethod · 0.80
ListObjectsMethod · 0.45

Tested by

no test coverage detected