diff options
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/README.md')
-rw-r--r-- | vendor/github.com/minio/minio-go/v7/README.md | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/README.md b/vendor/github.com/minio/minio-go/v7/README.md new file mode 100644 index 0000000..82f70a1 --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/README.md | |||
@@ -0,0 +1,312 @@ | |||
1 | # MinIO Go Client SDK for Amazon S3 Compatible Cloud Storage [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io) [![Sourcegraph](https://sourcegraph.com/github.com/minio/minio-go/-/badge.svg)](https://sourcegraph.com/github.com/minio/minio-go?badge) [![Apache V2 License](https://img.shields.io/badge/license-Apache%20V2-blue.svg)](https://github.com/minio/minio-go/blob/master/LICENSE) | ||
2 | |||
3 | The MinIO Go Client SDK provides straightforward APIs to access any Amazon S3 compatible object storage. | ||
4 | |||
5 | This Quickstart Guide covers how to install the MinIO client SDK, connect to MinIO, and create a sample file uploader. | ||
6 | For a complete list of APIs and examples, see the [godoc documentation](https://pkg.go.dev/github.com/minio/minio-go/v7) or [Go Client API Reference](https://min.io/docs/minio/linux/developers/go/API.html). | ||
7 | |||
8 | These examples presume a working [Go development environment](https://golang.org/doc/install) and the [MinIO `mc` command line tool](https://min.io/docs/minio/linux/reference/minio-mc.html). | ||
9 | |||
10 | ## Download from Github | ||
11 | |||
12 | From your project directory: | ||
13 | |||
14 | ```sh | ||
15 | go get github.com/minio/minio-go/v7 | ||
16 | ``` | ||
17 | |||
18 | ## Initialize a MinIO Client Object | ||
19 | |||
20 | The MinIO client requires the following parameters to connect to an Amazon S3 compatible object storage: | ||
21 | |||
22 | | Parameter | Description | | ||
23 | | ----------------- | ---------------------------------------------------------- | | ||
24 | | `endpoint` | URL to object storage service. | | ||
25 | | `_minio.Options_` | All the options such as credentials, custom transport etc. | | ||
26 | |||
27 | ```go | ||
28 | package main | ||
29 | |||
30 | import ( | ||
31 | "log" | ||
32 | |||
33 | "github.com/minio/minio-go/v7" | ||
34 | "github.com/minio/minio-go/v7/pkg/credentials" | ||
35 | ) | ||
36 | |||
37 | func main() { | ||
38 | endpoint := "play.min.io" | ||
39 | accessKeyID := "Q3AM3UQ867SPQQA43P2F" | ||
40 | secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" | ||
41 | useSSL := true | ||
42 | |||
43 | // Initialize minio client object. | ||
44 | minioClient, err := minio.New(endpoint, &minio.Options{ | ||
45 | Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), | ||
46 | Secure: useSSL, | ||
47 | }) | ||
48 | if err != nil { | ||
49 | log.Fatalln(err) | ||
50 | } | ||
51 | |||
52 | log.Printf("%#v\n", minioClient) // minioClient is now set up | ||
53 | } | ||
54 | ``` | ||
55 | |||
56 | ## Example - File Uploader | ||
57 | |||
58 | This sample code connects to an object storage server, creates a bucket, and uploads a file to the bucket. | ||
59 | It uses the MinIO `play` server, a public MinIO cluster located at [https://play.min.io](https://play.min.io). | ||
60 | |||
61 | The `play` server runs the latest stable version of MinIO and may be used for testing and development. | ||
62 | The access credentials shown in this example are open to the public and all data uploaded to `play` should be considered public and non-protected. | ||
63 | |||
64 | ### FileUploader.go | ||
65 | |||
66 | This example does the following: | ||
67 | |||
68 | - Connects to the MinIO `play` server using the provided credentials. | ||
69 | - Creates a bucket named `testbucket`. | ||
70 | - Uploads a file named `testdata` from `/tmp`. | ||
71 | - Verifies the file was created using `mc ls`. | ||
72 | |||
73 | ```go | ||
74 | // FileUploader.go MinIO example | ||
75 | package main | ||
76 | |||
77 | import ( | ||
78 | "context" | ||
79 | "log" | ||
80 | |||
81 | "github.com/minio/minio-go/v7" | ||
82 | "github.com/minio/minio-go/v7/pkg/credentials" | ||
83 | ) | ||
84 | |||
85 | func main() { | ||
86 | ctx := context.Background() | ||
87 | endpoint := "play.min.io" | ||
88 | accessKeyID := "Q3AM3UQ867SPQQA43P2F" | ||
89 | secretAccessKey := "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" | ||
90 | useSSL := true | ||
91 | |||
92 | // Initialize minio client object. | ||
93 | minioClient, err := minio.New(endpoint, &minio.Options{ | ||
94 | Creds: credentials.NewStaticV4(accessKeyID, secretAccessKey, ""), | ||
95 | Secure: useSSL, | ||
96 | }) | ||
97 | if err != nil { | ||
98 | log.Fatalln(err) | ||
99 | } | ||
100 | |||
101 | // Make a new bucket called testbucket. | ||
102 | bucketName := "testbucket" | ||
103 | location := "us-east-1" | ||
104 | |||
105 | err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location}) | ||
106 | if err != nil { | ||
107 | // Check to see if we already own this bucket (which happens if you run this twice) | ||
108 | exists, errBucketExists := minioClient.BucketExists(ctx, bucketName) | ||
109 | if errBucketExists == nil && exists { | ||
110 | log.Printf("We already own %s\n", bucketName) | ||
111 | } else { | ||
112 | log.Fatalln(err) | ||
113 | } | ||
114 | } else { | ||
115 | log.Printf("Successfully created %s\n", bucketName) | ||
116 | } | ||
117 | |||
118 | // Upload the test file | ||
119 | // Change the value of filePath if the file is in another location | ||
120 | objectName := "testdata" | ||
121 | filePath := "/tmp/testdata" | ||
122 | contentType := "application/octet-stream" | ||
123 | |||
124 | // Upload the test file with FPutObject | ||
125 | info, err := minioClient.FPutObject(ctx, bucketName, objectName, filePath, minio.PutObjectOptions{ContentType: contentType}) | ||
126 | if err != nil { | ||
127 | log.Fatalln(err) | ||
128 | } | ||
129 | |||
130 | log.Printf("Successfully uploaded %s of size %d\n", objectName, info.Size) | ||
131 | } | ||
132 | ``` | ||
133 | |||
134 | **1. Create a test file containing data:** | ||
135 | |||
136 | You can do this with `dd` on Linux or macOS systems: | ||
137 | |||
138 | ```sh | ||
139 | dd if=/dev/urandom of=/tmp/testdata bs=2048 count=10 | ||
140 | ``` | ||
141 | |||
142 | or `fsutil` on Windows: | ||
143 | |||
144 | ```sh | ||
145 | fsutil file createnew "C:\Users\<username>\Desktop\sample.txt" 20480 | ||
146 | ``` | ||
147 | |||
148 | **2. Run FileUploader with the following commands:** | ||
149 | |||
150 | ```sh | ||
151 | go mod init example/FileUploader | ||
152 | go get github.com/minio/minio-go/v7 | ||
153 | go get github.com/minio/minio-go/v7/pkg/credentials | ||
154 | go run FileUploader.go | ||
155 | ``` | ||
156 | |||
157 | The output resembles the following: | ||
158 | |||
159 | ```sh | ||
160 | 2023/11/01 14:27:55 Successfully created testbucket | ||
161 | 2023/11/01 14:27:55 Successfully uploaded testdata of size 20480 | ||
162 | ``` | ||
163 | |||
164 | **3. Verify the Uploaded File With `mc ls`:** | ||
165 | |||
166 | ```sh | ||
167 | mc ls play/testbucket | ||
168 | [2023-11-01 14:27:55 UTC] 20KiB STANDARD TestDataFile | ||
169 | ``` | ||
170 | |||
171 | ## API Reference | ||
172 | |||
173 | The full API Reference is available here. | ||
174 | |||
175 | * [Complete API Reference](https://min.io/docs/minio/linux/developers/go/API.html) | ||
176 | |||
177 | ### API Reference : Bucket Operations | ||
178 | |||
179 | * [`MakeBucket`](https://min.io/docs/minio/linux/developers/go/API.html#MakeBucket) | ||
180 | * [`ListBuckets`](https://min.io/docs/minio/linux/developers/go/API.html#ListBuckets) | ||
181 | * [`BucketExists`](https://min.io/docs/minio/linux/developers/go/API.html#BucketExists) | ||
182 | * [`RemoveBucket`](https://min.io/docs/minio/linux/developers/go/API.html#RemoveBucket) | ||
183 | * [`ListObjects`](https://min.io/docs/minio/linux/developers/go/API.html#ListObjects) | ||
184 | * [`ListIncompleteUploads`](https://min.io/docs/minio/linux/developers/go/API.html#ListIncompleteUploads) | ||
185 | |||
186 | ### API Reference : Bucket policy Operations | ||
187 | |||
188 | * [`SetBucketPolicy`](https://min.io/docs/minio/linux/developers/go/API.html#SetBucketPolicy) | ||
189 | * [`GetBucketPolicy`](https://min.io/docs/minio/linux/developers/go/API.html#GetBucketPolicy) | ||
190 | |||
191 | ### API Reference : Bucket notification Operations | ||
192 | |||
193 | * [`SetBucketNotification`](https://min.io/docs/minio/linux/developers/go/API.html#SetBucketNotification) | ||
194 | * [`GetBucketNotification`](https://min.io/docs/minio/linux/developers/go/API.html#GetBucketNotification) | ||
195 | * [`RemoveAllBucketNotification`](https://min.io/docs/minio/linux/developers/go/API.html#RemoveAllBucketNotification) | ||
196 | * [`ListenBucketNotification`](https://min.io/docs/minio/linux/developers/go/API.html#ListenBucketNotification) (MinIO Extension) | ||
197 | * [`ListenNotification`](https://min.io/docs/minio/linux/developers/go/API.html#ListenNotification) (MinIO Extension) | ||
198 | |||
199 | ### API Reference : File Object Operations | ||
200 | |||
201 | * [`FPutObject`](https://min.io/docs/minio/linux/developers/go/API.html#FPutObject) | ||
202 | * [`FGetObject`](https://min.io/docs/minio/linux/developers/go/API.html#FGetObject) | ||
203 | |||
204 | ### API Reference : Object Operations | ||
205 | |||
206 | * [`GetObject`](https://min.io/docs/minio/linux/developers/go/API.html#GetObject) | ||
207 | * [`PutObject`](https://min.io/docs/minio/linux/developers/go/API.html#PutObject) | ||
208 | * [`PutObjectStreaming`](https://min.io/docs/minio/linux/developers/go/API.html#PutObjectStreaming) | ||
209 | * [`StatObject`](https://min.io/docs/minio/linux/developers/go/API.html#StatObject) | ||
210 | * [`CopyObject`](https://min.io/docs/minio/linux/developers/go/API.html#CopyObject) | ||
211 | * [`RemoveObject`](https://min.io/docs/minio/linux/developers/go/API.html#RemoveObject) | ||
212 | * [`RemoveObjects`](https://min.io/docs/minio/linux/developers/go/API.html#RemoveObjects) | ||
213 | * [`RemoveIncompleteUpload`](https://min.io/docs/minio/linux/developers/go/API.html#RemoveIncompleteUpload) | ||
214 | * [`SelectObjectContent`](https://min.io/docs/minio/linux/developers/go/API.html#SelectObjectContent) | ||
215 | |||
216 | ### API Reference : Presigned Operations | ||
217 | |||
218 | * [`PresignedGetObject`](https://min.io/docs/minio/linux/developers/go/API.html#PresignedGetObject) | ||
219 | * [`PresignedPutObject`](https://min.io/docs/minio/linux/developers/go/API.html#PresignedPutObject) | ||
220 | * [`PresignedHeadObject`](https://min.io/docs/minio/linux/developers/go/API.html#PresignedHeadObject) | ||
221 | * [`PresignedPostPolicy`](https://min.io/docs/minio/linux/developers/go/API.html#PresignedPostPolicy) | ||
222 | |||
223 | ### API Reference : Client custom settings | ||
224 | |||
225 | * [`SetAppInfo`](https://min.io/docs/minio/linux/developers/go/API.html#SetAppInfo) | ||
226 | * [`TraceOn`](https://min.io/docs/minio/linux/developers/go/API.html#TraceOn) | ||
227 | * [`TraceOff`](https://min.io/docs/minio/linux/developers/go/API.html#TraceOff) | ||
228 | |||
229 | ## Full Examples | ||
230 | |||
231 | ### Full Examples : Bucket Operations | ||
232 | |||
233 | * [makebucket.go](https://github.com/minio/minio-go/blob/master/examples/s3/makebucket.go) | ||
234 | * [listbuckets.go](https://github.com/minio/minio-go/blob/master/examples/s3/listbuckets.go) | ||
235 | * [bucketexists.go](https://github.com/minio/minio-go/blob/master/examples/s3/bucketexists.go) | ||
236 | * [removebucket.go](https://github.com/minio/minio-go/blob/master/examples/s3/removebucket.go) | ||
237 | * [listobjects.go](https://github.com/minio/minio-go/blob/master/examples/s3/listobjects.go) | ||
238 | * [listobjectsV2.go](https://github.com/minio/minio-go/blob/master/examples/s3/listobjectsV2.go) | ||
239 | * [listincompleteuploads.go](https://github.com/minio/minio-go/blob/master/examples/s3/listincompleteuploads.go) | ||
240 | |||
241 | ### Full Examples : Bucket policy Operations | ||
242 | |||
243 | * [setbucketpolicy.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketpolicy.go) | ||
244 | * [getbucketpolicy.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketpolicy.go) | ||
245 | * [listbucketpolicies.go](https://github.com/minio/minio-go/blob/master/examples/s3/listbucketpolicies.go) | ||
246 | |||
247 | ### Full Examples : Bucket lifecycle Operations | ||
248 | |||
249 | * [setbucketlifecycle.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketlifecycle.go) | ||
250 | * [getbucketlifecycle.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketlifecycle.go) | ||
251 | |||
252 | ### Full Examples : Bucket encryption Operations | ||
253 | |||
254 | * [setbucketencryption.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketencryption.go) | ||
255 | * [getbucketencryption.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketencryption.go) | ||
256 | * [deletebucketencryption.go](https://github.com/minio/minio-go/blob/master/examples/s3/deletebucketencryption.go) | ||
257 | |||
258 | ### Full Examples : Bucket replication Operations | ||
259 | |||
260 | * [setbucketreplication.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketreplication.go) | ||
261 | * [getbucketreplication.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketreplication.go) | ||
262 | * [removebucketreplication.go](https://github.com/minio/minio-go/blob/master/examples/s3/removebucketreplication.go) | ||
263 | |||
264 | ### Full Examples : Bucket notification Operations | ||
265 | |||
266 | * [setbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketnotification.go) | ||
267 | * [getbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketnotification.go) | ||
268 | * [removeallbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/s3/removeallbucketnotification.go) | ||
269 | * [listenbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/minio/listenbucketnotification.go) (MinIO Extension) | ||
270 | * [listennotification.go](https://github.com/minio/minio-go/blob/master/examples/minio/listen-notification.go) (MinIO Extension) | ||
271 | |||
272 | ### Full Examples : File Object Operations | ||
273 | |||
274 | * [fputobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/fputobject.go) | ||
275 | * [fgetobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/fgetobject.go) | ||
276 | |||
277 | ### Full Examples : Object Operations | ||
278 | |||
279 | * [putobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/putobject.go) | ||
280 | * [getobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/getobject.go) | ||
281 | * [statobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/statobject.go) | ||
282 | * [copyobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/copyobject.go) | ||
283 | * [removeobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/removeobject.go) | ||
284 | * [removeincompleteupload.go](https://github.com/minio/minio-go/blob/master/examples/s3/removeincompleteupload.go) | ||
285 | * [removeobjects.go](https://github.com/minio/minio-go/blob/master/examples/s3/removeobjects.go) | ||
286 | |||
287 | ### Full Examples : Encrypted Object Operations | ||
288 | |||
289 | * [put-encrypted-object.go](https://github.com/minio/minio-go/blob/master/examples/s3/put-encrypted-object.go) | ||
290 | * [get-encrypted-object.go](https://github.com/minio/minio-go/blob/master/examples/s3/get-encrypted-object.go) | ||
291 | * [fput-encrypted-object.go](https://github.com/minio/minio-go/blob/master/examples/s3/fputencrypted-object.go) | ||
292 | |||
293 | ### Full Examples : Presigned Operations | ||
294 | |||
295 | * [presignedgetobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/presignedgetobject.go) | ||
296 | * [presignedputobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/presignedputobject.go) | ||
297 | * [presignedheadobject.go](https://github.com/minio/minio-go/blob/master/examples/s3/presignedheadobject.go) | ||
298 | * [presignedpostpolicy.go](https://github.com/minio/minio-go/blob/master/examples/s3/presignedpostpolicy.go) | ||
299 | |||
300 | ## Explore Further | ||
301 | |||
302 | * [Godoc Documentation](https://pkg.go.dev/github.com/minio/minio-go/v7) | ||
303 | * [Complete Documentation](https://min.io/docs/minio/kubernetes/upstream/index.html) | ||
304 | * [MinIO Go Client SDK API Reference](https://min.io/docs/minio/linux/developers/go/API.html) | ||
305 | |||
306 | ## Contribute | ||
307 | |||
308 | [Contributors Guide](https://github.com/minio/minio-go/blob/master/CONTRIBUTING.md) | ||
309 | |||
310 | ## License | ||
311 | |||
312 | This SDK is distributed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), see [LICENSE](https://github.com/minio/minio-go/blob/master/LICENSE) and [NOTICE](https://github.com/minio/minio-go/blob/master/NOTICE) for more information. | ||