@@ -12,6 +12,8 @@ var minioClient *minio.Client
12
12
13
13
func init () {
14
14
var err error
15
+ //s3.amazonaws.com
16
+ //127.0.0.1:9000
15
17
minioClient , err = minio .New ("127.0.0.1:9000" , "AKIAINCHU2DIYAQ66TPA" , "ZaYtz0d61fJXQ7djyXBX4yZ5ob8Kj/WNXtw6PJob" , false )
16
18
if err != nil {
17
19
panic (err )
@@ -34,6 +36,49 @@ func TestGetObject(t *testing.T) {
34
36
}
35
37
fmt .Println (string (data ))
36
38
}
39
+ func TestPutObject (t * testing.T ) {
40
+ /*_,err:=minioClient.PutObject("test","3",strings.NewReader("3"),int64(len("1")),minio.PutObjectOptions{})
41
+ if err != nil {
42
+ panic(err)
43
+ }*/
44
+ info ,err := minioClient .StatObject ("test" ,"1" ,minio.StatObjectOptions {})
45
+ if err != nil {
46
+ panic (err )
47
+ }
48
+ fmt .Println (info )
49
+ fmt .Println (info .ETag )
50
+ }
51
+
52
+
53
+ func TestComposeObject (t * testing.T ) {
54
+ bucketName := "test"
55
+ var srcs = make ([]minio.SourceInfo ,0 )
56
+ for i := 0 ;i < 3 ;i ++ {
57
+ name := fmt .Sprintf ("sheet_%d" ,i )
58
+ bbuf := bytes .Repeat ([]byte (fmt .Sprint (i + 1 )), 1024 * 1025 * 5 )//至少要5M
59
+
60
+ index ,err := minioClient .PutObject (bucketName ,name ,bytes .NewReader (bbuf ),int64 (len (bbuf )),minio.PutObjectOptions {})
61
+ if err != nil {
62
+ panic (err )
63
+ }
64
+ fmt .Println (index )
65
+ srcs = append (srcs ,minio .NewSourceInfo (bucketName ,fmt .Sprintf ("sheet_%d" ,i ),nil ))
66
+ }
67
+ fmt .Println (srcs )
68
+ dst , err := minio .NewDestinationInfo ("test" , "222.log" , nil , nil )
69
+ if err != nil {
70
+ fmt .Println (err )
71
+ return
72
+ }
73
+ fmt .Println (dst )
74
+ err = minioClient .ComposeObject (dst , srcs )
75
+ if err != nil {
76
+ fmt .Println (err )
77
+ return
78
+ }
79
+ fmt .Println ("Composed object successfully." )
80
+ }
81
+
37
82
38
83
func TestNewMultipartUpload (t * testing.T ) {
39
84
daya := minio.Core {Client : minioClient }
@@ -46,7 +91,8 @@ func TestNewMultipartUpload(t *testing.T) {
46
91
}
47
92
48
93
func TestNewPutObjectPart (t * testing.T ) {
49
- abuf := bytes .Repeat ([]byte ("aaaaa" ), 1024 * 1024 )//至少要5MB 才能使用分片上传
94
+ abuf := bytes .Repeat ([]byte ("aaaaa" ), 1024 * 1024 )//至少要5MB 才能使用分片上传(不包含最后一片)
95
+ fmt .Println (len (abuf ))
50
96
bbuf := bytes .Repeat ([]byte ("b" ), 1024 * 1024 )
51
97
daya := minio.Core {Client : minioClient }
52
98
bucket := "test"
@@ -77,3 +123,18 @@ func TestNewPutObjectPart(t *testing.T) {
77
123
panic (err )
78
124
}
79
125
}
126
+
127
+ func TestConsolidatedFile (t * testing.T ) {
128
+ bucketName := "test"
129
+ var srcs = make ([]minio.SourceInfo ,0 )
130
+ for i := 0 ;i < 3 ;i ++ {
131
+ name := fmt .Sprintf ("sheet_%d" ,i )
132
+ bbuf := bytes .Repeat ([]byte (fmt .Sprint (i + 1 )), 1 )//至少要5M
133
+ index ,err := minioClient .PutObject (bucketName ,name ,bytes .NewReader (bbuf ),int64 (len (bbuf )),minio.PutObjectOptions {})
134
+ if err != nil {
135
+ panic (err )
136
+ }
137
+ fmt .Println (index )
138
+ srcs = append (srcs ,minio .NewSourceInfo (bucketName ,fmt .Sprintf ("sheet_%d" ,i ),nil ))
139
+ }
140
+ }
0 commit comments