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

Function main

examples/minio/put-object-fan-out.go:35–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33)
34
35func main() {
36 const (
37 // Note: These constants are dummy values,
38 // please replace them with values for your setup.
39 YOURACCESSKEYID = "Q3AM3UQ867SPQQA43P2F"
40 YOURSECRETACCESSKEY = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
41 YOURENDPOINT = "play.min.io"
42 YOURBUCKET = "mybucket" // 'mc mb play/mybucket' if it does not exist.
43 )
44
45 // Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
46 // This boolean value is the last argument for New().
47
48 // New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
49 // determined based on the Endpoint value.
50 minioClient, err := minio.New(YOURENDPOINT, &minio.Options{
51 Creds: credentials.NewStaticV4(YOURACCESSKEYID, YOURSECRETACCESSKEY, ""),
52 Secure: true,
53 })
54 if err != nil {
55 log.Fatalln(err)
56 }
57
58 // Enable tracing.
59 minioClient.TraceOn(os.Stdout)
60
61 filePath := "my-testfile" // Specify a local file that we will upload
62
63 // Open a local file that we will upload
64 file, err := os.Open(filePath)
65 if err != nil {
66 log.Fatalln(err)
67 }
68 defer file.Close()
69
70 cs, err := minio.ChecksumCRC32C.ChecksumReader(file)
71 if err != nil {
72 log.Fatalln(err)
73 }
74
75 // Seek to beginning before upload.
76 file.Seek(0, io.SeekStart)
77
78 fanOutReq := minio.PutObjectFanOutRequest{
79 Entries: []minio.PutObjectFanOutEntry{
80 {Key: "my1-prefix/1.txt"},
81 {Key: "my1-prefix/2.txt"},
82 {Key: "my1-prefix/3.txt"},
83 {Key: "my1-prefix/4.txt"},
84 {Key: "my1-prefix/5.txt"},
85 {Key: "my1-prefix/6.txt"},
86 },
87 SSE: encrypt.NewSSE(),
88 Checksum: cs,
89 }
90
91 fanOutResp, err := minioClient.PutObjectFanOut(context.Background(), YOURBUCKET, file, fanOutReq)
92 if err != nil {

Callers

nothing calls this directly

Calls 7

NewStaticV4Function · 0.92
NewSSEFunction · 0.92
TraceOnMethod · 0.80
ChecksumReaderMethod · 0.80
PutObjectFanOutMethod · 0.80
CloseMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected