Initializes minio client, with region configured. Unlike New(), NewWithRegion avoids bucket-location lookup operations and it is slightly faster. Use this function when your application deals with a single region.

NewWithOptions(endpoint string, options Options) (Client, error)

Initializes minio client with options configured.

Parameters

Param

Type

Description

endpoint

string

S3 compatible object storage endpoint

opts

minio.Options

Options for constructing a new client

minio.Options

Field

Type

Description

opts.Creds

*credentials.Credentials

Access Credentials

opts.Secure

bool

If 'true' API requests will be secure (HTTPS), and insecure (HTTP) otherwise

opts.Region

string

region

opts.BucketLookup

BucketLookupType

Bucket lookup type can be one of the following values

minio.BucketLookupDNS

minio.BucketLookupPath

minio.BucketLookupAuto

2. Bucket operations

MakeBucket(bucketName, location string) error

Creates a new bucket.

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).

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.

Parameters

Param

Type

Description

bucketName

string

Name of the bucket

objectName

string

Name of the object

reader

io.Reader

Any Go type that implements io.Reader

objectSize

int64

Size of the object being uploaded. Pass -1 if stream size is unknown

opts

minio.PutObjectOptions

Allows user to set optional custom metadata, content headers, encryption keys and number of threads for multipart upload operation.

minio.PutObjectOptions

Field

Type

Description

opts.UserMetadata

map[string]string

Map of user metadata

opts.Progress

io.Reader

Reader to fetch progress of an upload

opts.ContentType

string

Content type of object, e.g "application/text"

opts.ContentEncoding

string

Content encoding of object, e.g "gzip"

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"

API methods PutObjectWithSize, PutObjectWithMetadata, PutObjectStreaming, and PutObjectWithProgress available in minio-go SDK release v3.0.3 are replaced by the new PutObject call variant that accepts a pointer to PutObjectOptions struct.

CopyObject(dst DestinationInfo, src SourceInfo) error

Create or replace an object through server-side copying of an existing object. It supports conditional copying, copying a part of an object and server-side encryption of destination and decryption of source. See the SourceInfo and DestinationInfo types for further details.

To copy multiple source objects into a single destination object see the ComposeObject API.

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.

5. Presigned operations

Generates a presigned URL for HTTP GET operations. Browsers/Mobile clients may point to this URL to directly download objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.

Generates a presigned URL for HTTP PUT operations. Browsers/Mobile clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.

Generates a presigned URL for HTTP HEAD operations. Browsers/Mobile clients may point to this URL to directly get metadata from objects even if the bucket is private. This presigned URL can have an associated expiration time in seconds after which it is no longer operational. The default expiry is set to 7 days.