summaryrefslogtreecommitdiff
path: root/docs/API.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/API.md')
-rw-r--r--docs/API.md308
1 files changed, 278 insertions, 30 deletions
diff --git a/docs/API.md b/docs/API.md
index 5778216..f17487d 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -1,8 +1,8 @@
-# Minio Go Client API Reference [![Slack](https://slack.minio.io/slack?type=svg)](https://slack.minio.io)
+# MinIO Go Client API Reference [![Slack](https://slack.min.io/slack?type=svg)](https://slack.min.io)
-## Initialize Minio Client object.
+## Initialize MinIO Client object.
-## Minio
+## MinIO
```go
package main
@@ -10,7 +10,7 @@ package main
import (
"fmt"
- "github.com/minio/minio-go"
+ "github.com/minio/minio-go/v6"
)
func main() {
@@ -18,7 +18,7 @@ func main() {
ssl := true
// Initialize minio client object.
- minioClient, err := minio.New("play.minio.io:9000", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
+ minioClient, err := minio.New("play.min.io", "Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ssl)
if err != nil {
fmt.Println(err)
return
@@ -34,7 +34,7 @@ package main
import (
"fmt"
- "github.com/minio/minio-go"
+ "github.com/minio/minio-go/v6"
)
func main() {
@@ -53,25 +53,28 @@ func main() {
| Bucket operations | Object operations | Encrypted Object operations | Presigned operations | Bucket Policy/Notification Operations | Client custom settings |
| :--- | :--- | :--- | :--- | :--- | :--- |
| [`MakeBucket`](#MakeBucket) | [`GetObject`](#GetObject) | [`GetObject`](#GetObject) | [`PresignedGetObject`](#PresignedGetObject) | [`SetBucketPolicy`](#SetBucketPolicy) | [`SetAppInfo`](#SetAppInfo) |
-| [`ListBuckets`](#ListBuckets) | [`PutObject`](#PutObject) | [`PutObject`](#PutObject) | [`PresignedPutObject`](#PresignedPutObject) | [`GetBucketPolicy`](#GetBucketPolicy) | [`SetCustomTransport`](#SetCustomTransport) |
-| [`BucketExists`](#BucketExists) | [`CopyObject`](#CopyObject) | [`CopyObject`](#CopyObject) | [`PresignedPostPolicy`](#PresignedPostPolicy) | [`SetBucketNotification`](#SetBucketNotification) | [`TraceOn`](#TraceOn) |
-| [`RemoveBucket`](#RemoveBucket) | [`StatObject`](#StatObject) | [`StatObject`](#StatObject) | | [`GetBucketNotification`](#GetBucketNotification) | [`TraceOff`](#TraceOff) |
-| [`ListObjects`](#ListObjects) | [`RemoveObject`](#RemoveObject) | | | [`RemoveAllBucketNotification`](#RemoveAllBucketNotification) | [`SetS3TransferAccelerate`](#SetS3TransferAccelerate) |
-| [`ListObjectsV2`](#ListObjectsV2) | [`RemoveObjects`](#RemoveObjects) | | | [`ListenBucketNotification`](#ListenBucketNotification) | |
-| [`ListIncompleteUploads`](#ListIncompleteUploads) | [`RemoveIncompleteUpload`](#RemoveIncompleteUpload) | | | [`SetBucketLifecycle`](#SetBucketLifecycle) | |
-| | [`FPutObject`](#FPutObject) | [`FPutObject`](#FPutObject) | | [`GetBucketLifecycle`](#GetBucketLifecycle) | |
-| | [`FGetObject`](#FGetObject) | [`FGetObject`](#FGetObject) | | | |
-| | [`ComposeObject`](#ComposeObject) | [`ComposeObject`](#ComposeObject) | | | |
-| | [`NewSourceInfo`](#NewSourceInfo) | [`NewSourceInfo`](#NewSourceInfo) | | | |
-| | [`NewDestinationInfo`](#NewDestinationInfo) | [`NewDestinationInfo`](#NewDestinationInfo) | | | |
+| [`MakeBucketWithObjectLock`](#MakeBucketWithObjectLock) | [`PutObject`](#PutObject) | [`PutObject`](#PutObject) | [`PresignedPutObject`](#PresignedPutObject) | [`GetBucketPolicy`](#GetBucketPolicy) | [`SetCustomTransport`](#SetCustomTransport) |
+| [`ListBuckets`](#ListBuckets) | [`CopyObject`](#CopyObject) | [`CopyObject`](#CopyObject) | [`PresignedPostPolicy`](#PresignedPostPolicy) | [`SetBucketNotification`](#SetBucketNotification) | [`TraceOn`](#TraceOn) |
+| [`BucketExists`](#BucketExists) | [`StatObject`](#StatObject) | [`StatObject`](#StatObject) | | [`GetBucketNotification`](#GetBucketNotification) | [`TraceOff`](#TraceOff) |
+| [`RemoveBucket`](#RemoveBucket) | [`RemoveObject`](#RemoveObject) | | | [`RemoveAllBucketNotification`](#RemoveAllBucketNotification) | [`SetS3TransferAccelerate`](#SetS3TransferAccelerate) |
+| [`ListObjects`](#ListObjects) | [`RemoveObjects`](#RemoveObjects) | | | [`ListenBucketNotification`](#ListenBucketNotification) | |
+| [`ListObjectsV2`](#ListObjectsV2) | [`RemoveIncompleteUpload`](#RemoveIncompleteUpload) | | | [`SetBucketLifecycle`](#SetBucketLifecycle) | |
+| [`ListIncompleteUploads`](#ListIncompleteUploads) | [`FPutObject`](#FPutObject) | [`FPutObject`](#FPutObject) | | [`GetBucketLifecycle`](#GetBucketLifecycle) | |
+| | [`FGetObject`](#FGetObject) | [`FGetObject`](#FGetObject) | | [`SetBucketObjectLockConfig`](#SetBucketObjectLockConfig) | |
+| | [`ComposeObject`](#ComposeObject) | [`ComposeObject`](#ComposeObject) | | [`GetBucketObjectLockConfig`](#GetBucketObjectLockConfig) | |
+| | [`NewSourceInfo`](#NewSourceInfo) | [`NewSourceInfo`](#NewSourceInfo) | | [`EnableVersioning`](#EnableVersioning) | |
+| | [`NewDestinationInfo`](#NewDestinationInfo) | [`NewDestinationInfo`](#NewDestinationInfo) | | [`DisableVersioning`](#DisableVersioning) | |
| | [`PutObjectWithContext`](#PutObjectWithContext) | [`PutObjectWithContext`](#PutObjectWithContext) | | |
| | [`GetObjectWithContext`](#GetObjectWithContext) | [`GetObjectWithContext`](#GetObjectWithContext) | | |
| | [`FPutObjectWithContext`](#FPutObjectWithContext) | [`FPutObjectWithContext`](#FPutObjectWithContext) | | |
| | [`FGetObjectWithContext`](#FGetObjectWithContext) | [`FGetObjectWithContext`](#FGetObjectWithContext) | | |
| | [`RemoveObjectsWithContext`](#RemoveObjectsWithContext) | | | |
+| | [`RemoveObjectWithOptions`](#RemoveObjectWithOptions) | | | |
+| | [`PutObjectRetention`](#PutObjectRetention) | | | |
+| | [`GetObjectRetention`](#GetObjectRetention) | | | |
| | [`SelectObjectContent`](#SelectObjectContent) | |
## 1. Constructor
-<a name="Minio"></a>
+<a name="MinIO"></a>
### New(endpoint, accessKeyID, secretAccessKey string, ssl bool) (*Client, error)
Initializes a new client object.
@@ -144,6 +147,39 @@ if err != nil {
fmt.Println("Successfully created mybucket.")
```
+<a name="MakeBucketWithObjectLock"></a>
+### MakeBucketWithObjectLock(bucketName, location string) error
+Creates a new bucket with object lock enabled.
+
+__Parameters__
+
+| Param | Type | Description |
+|---|---|---|
+|`bucketName` | _string_ | Name of the bucket |
+| `location` | _string_ | Region where the bucket is to be created. Default value is us-east-1. Other valid values are listed below. Note: When used with minio server, use the region specified in its config file (defaults to us-east-1).|
+| | |us-east-1 |
+| | |us-west-1 |
+| | |us-west-2 |
+| | |eu-west-1 |
+| | | eu-central-1|
+| | | ap-southeast-1|
+| | | ap-northeast-1|
+| | | ap-southeast-2|
+| | | sa-east-1|
+
+
+__Example__
+
+
+```go
+err = minioClient.MakeBucketWithObjectLock("mybucket", "us-east-1")
+if err != nil {
+ fmt.Println(err)
+ return
+}
+fmt.Println("Successfully created mybucket.")
+```
+
<a name="ListBuckets"></a>
### ListBuckets() ([]BucketInfo, error)
Lists all buckets.
@@ -393,7 +429,7 @@ __minio.GetObjectOptions__
|Field | Type | Description |
|:---|:---|:---|
-| `opts.ServerSideEncryption` | _encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go) |
+| `opts.ServerSideEncryption` | _encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go/v6) |
__Return Value__
@@ -528,7 +564,7 @@ if err != nil {
<a name="PutObject"></a>
### PutObject(bucketName, objectName string, reader io.Reader, objectSize int64,opts PutObjectOptions) (n int, err error)
-Uploads objects that are less than 64MiB in a single PUT operation. For objects that are greater than 64MiB in size, PutObject seamlessly uploads the object as parts of 64MiB or more depending on the actual file size. The max upload size for an object is 5TB.
+Uploads objects that are less than 128MiB in a single PUT operation. For objects that are greater than 128MiB in size, PutObject seamlessly uploads the object as parts of 128MiB or more depending on the actual file size. The max upload size for an object is 5TB.
__Parameters__
@@ -552,8 +588,10 @@ __minio.PutObjectOptions__
| `opts.ContentDisposition` | _string_ | Content disposition of object, "inline" |
| `opts.ContentLanguage` | _string_ | Content language of object, e.g "French" |
| `opts.CacheControl` | _string_ | Used to specify directives for caching mechanisms in both requests and responses e.g "max-age=600"|
-| `opts.ServerSideEncryption` | _encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go) |
-| `opts.StorageClass` | _string_ | Specify storage class for the object. Supported values for Minio server are `REDUCED_REDUNDANCY` and `STANDARD` |
+| `opts.Mode` | _*minio.RetentionMode_ | Retention mode to be set, e.g "COMPLIANCE" |
+| `opts.RetainUntilDate` | _*time.Time_ | Time until which the retention applied is valid|
+| `opts.ServerSideEncryption` | _encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go/v6) |
+| `opts.StorageClass` | _string_ | Specify storage class for the object. Supported values for MinIO server are `REDUCED_REDUNDANCY` and `STANDARD` |
| `opts.WebsiteRedirectLocation` | _string_ | Specify a redirect for the object, to another object in the same bucket or to a external URL. |
__Example__
@@ -771,7 +809,7 @@ __Parameters__
| :--- | :--- | :--- |
| `bucket` | _string_ | Name of the source bucket |
| `object` | _string_ | Name of the source object |
-| `sse` | _*encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go) |
+| `sse` | _*encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go/v6) |
__Example__
@@ -824,7 +862,7 @@ __Parameters__
| :--- | :--- | :--- |
| `bucket` | _string_ | Name of the destination bucket |
| `object` | _string_ | Name of the destination object |
-| `sse` | _*encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go) | |
+| `sse` | _*encrypt.ServerSide_ | Interface provided by `encrypt` package to specify server-side-encryption. (For more information see https://godoc.org/github.com/minio/minio-go/v6) | |
| `userMeta` | _map[string]string_ | User metadata to be set on the destination. If nil, with only one source, user-metadata is copied from source. |
__Example__
@@ -869,7 +907,7 @@ if err != nil {
### FPutObject(bucketName, objectName, filePath, opts PutObjectOptions) (length int64, err error)
Uploads contents from a file to objectName.
-FPutObject uploads objects that are less than 64MiB in a single PUT operation. For objects that are greater than the 64MiB in size, FPutObject seamlessly uploads the object in chunks of 64MiB or more depending on the actual file size. The max upload size for an object is 5TB.
+FPutObject uploads objects that are less than 128MiB in a single PUT operation. For objects that are greater than the 128MiB in size, FPutObject seamlessly uploads the object in chunks of 128MiB or more depending on the actual file size. The max upload size for an object is 5TB.
__Parameters__
@@ -1069,6 +1107,94 @@ for rErr := range minioClient.RemoveObjects(ctx, "my-bucketname", objectsCh) {
fmt.Println("Error detected during deletion: ", rErr)
}
```
+<a name="RemoveObjectWithOptions"></a>
+### RemoveObjectWithOptions(bucketName, objectName string, opts minio.RemoveObjectOptions) error
+Removes an object.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+|`objectName` | _string_ |Name of the object |
+|`opts` |_minio.RemoveObjectOptions_ |Allows user to set options |
+
+__minio.RemoveObjectOptions__
+
+|Field | Type | Description |
+|:--- |:--- | :--- |
+| `opts.GovernanceBypass` | _bool_ |Set the bypass governance header to delete an object locked with GOVERNANCE mode|
+| `opts.VersionID` | _string_ |Version ID of the object to delete|
+
+
+```go
+opts := minio.RemoveObjectOptions {
+ GovernanceBypass: true,
+ VersionID: "myversionid",
+ }
+err = minioClient.RemoveObjectWithOptions("mybucket", "myobject", opts)
+if err != nil {
+ fmt.Println(err)
+ return
+}
+```
+<a name="PutObjectRetention"></a>
+### PutObjectRetention(bucketName, objectName string, opts minio.PutObjectRetentionOptions) error
+Applies object retention lock onto an object.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+|`objectName` | _string_ |Name of the object |
+|`opts` |_minio.PutObjectRetentionOptions_ |Allows user to set options like retention mode, expiry date and version id |
+
+__minio.PutObjectRetentionOptions__
+
+|Field | Type | Description |
+|:--- |:--- | :--- |
+| `opts.GovernanceBypass` | _bool_ |Set the bypass governance header to overwrite object retention if the existing retention mode is set to GOVERNANCE|
+| `opts.Mode` | _*minio.RetentionMode_ |Retention mode to be set|
+| `opts.RetainUntilDate` | _*time.Time_ |Time until which the retention applied is valid|
+| `opts.VersionID` | _string_ |Version ID of the object to apply retention on|
+
+```go
+t := time.Date(2020, time.November, 18, 14, 0, 0, 0, time.UTC)
+m := minio.RetentionMode(minio.Compliance)
+opts := minio.PutObjectRetentionOptions {
+ GovernanceBypass: true,
+ RetainUntilDate: &t,
+ Mode: &m,
+ }
+err = minioClient.PutObjectRetention("mybucket", "myobject", opts)
+if err != nil {
+ fmt.Println(err)
+ return
+}
+```
+<a name="GetObjectRetention"></a>
+### GetObjectRetention(bucketName, objectName, versionID string) (mode *RetentionMode, retainUntilDate *time.Time, err error)
+Returns retention set on a given object.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+|`objectName` | _string_ |Name of the object |
+|`versionID` |_string_ |Version ID of the object |
+
+```go
+err = minioClient.PutObjectRetention("mybucket", "myobject", "")
+if err != nil {
+ fmt.Println(err)
+ return
+}
+```
<a name="SelectObjectContent"></a>
### SelectObjectContent(ctx context.Context, bucketName string, objectsName string, expression string, options SelectObjectOptions) *SelectResults
Parameters
@@ -1565,6 +1691,133 @@ if err != nil {
}
```
+<a name="SetBucketObjectLockConfig"></a>
+### SetBucketObjectLockConfig(bucketname, mode *RetentionMode, validity *uint, unit *ValidityUnit) error
+Set object lock configuration in given bucket. mode, validity and unit are either all set or all nil.
+
+__Parameters__
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket|
+|`mode` | _RetentionMode_ |Retention mode to be set |
+|`validity` | _uint_ |Validity period to be set |
+|`unit` | _ValidityUnit_ |Unit of validity period |
+
+__Return Values__
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`err` | _error_ |Standard Error |
+
+__Example__
+
+```go
+mode := Governance
+validity := uint(30)
+unit := Days
+
+err = minioClient.SetBucketObjectLockConfig("my-bucketname", &mode, &validity, &unit)
+if err != nil {
+ fmt.Println(err)
+ return
+}
+```
+
+<a name="GetBucketObjectLockConfig"></a>
+### GetBucketObjectLockConfig(bucketName) (*RetentionMode, *uint, *ValidityUnit, error)
+Get object lock configuration of given bucket.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+
+__Return Values__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`mode` | _RetentionMode_ |Current retention mode |
+|`validity` | _uint_ |Current validity period |
+|`unit` | _ValidityUnit_ |Unit of validity period |
+|`err` | _error_ |Standard Error |
+
+__Example__
+
+```go
+mode, validity, unit, err := minioClient.GetObjectLockConfig("my-bucketname")
+if err != nil {
+ log.Fatalln(err)
+}
+
+if mode != nil {
+ fmt.Printf("%v mode is enabled for %v %v for bucket 'my-bucketname'\n", *mode, *validity, *unit)
+} else {
+ fmt.Println("No mode is enabled for bucket 'my-bucketname'")
+}
+```
+
+<a name="EnableVersioning"></a>
+### EnableVersioning(bucketName) error
+Enable bucket versioning support.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+
+__Return Values__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`err` | _error_ |Standard Error |
+
+__Example__
+
+```go
+err := minioClient.EnableVersioning("my-bucketname")
+if err != nil {
+ log.Fatalln(err)
+}
+
+fmt.Println("versioning enabled for bucket 'my-bucketname'")
+```
+
+<a name="DisableVersioning"></a>
+### DisableVersioning(bucketName) error
+Disable bucket versioning support.
+
+__Parameters__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`bucketName` | _string_ |Name of the bucket |
+
+__Return Values__
+
+
+|Param |Type |Description |
+|:---|:---| :---|
+|`err` | _error_ |Standard Error |
+
+__Example__
+
+```go
+err := minioClient.DisableVersioning("my-bucketname")
+if err != nil {
+ log.Fatalln(err)
+}
+
+fmt.Println("versioning disabled for bucket 'my-bucketname'")
+```
+
## 7. Client custom settings
<a name="SetAppInfo"></a>
@@ -1623,8 +1876,3 @@ __Parameters__
| Param | Type | Description |
|---|---|---|
|`acceleratedEndpoint` | _string_ | Set to new S3 transfer acceleration endpoint.|
-
-
-## 8. Explore Further
-
-- [Build your own Go Music Player App example](https://docs.minio.io/docs/go-music-player-app)