2015-11-06 15:31:59 -06:00
# Minio Go Library for Amazon S3 Compatible Cloud Storage [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2015-12-28 21:23:53 +01:00
## Description
Minio Go library is a simple client library for S3 compatible cloud storage servers. Supports AWS Signature Version 4 and 2. AWS Signature Version 4 is chosen as default.
List of supported cloud storage providers.
- AWS Signature Version 4
- Amazon S3
- Minio
- AWS Signature Version 2
- Google Cloud Storage (Compatibility Mode)
- Openstack Swift + Swift3 middleware
- Ceph Object Gateway
- Riak CS
2015-11-06 15:31:59 -06:00
## Install
2015-12-28 21:23:53 +01:00
If you do not have a working Golang environment, please follow [Install Golang ](./INSTALLGO.md ).
2015-11-06 15:31:59 -06:00
```sh
$ go get github.com/minio/minio-go
```
2015-12-28 21:23:53 +01:00
2015-11-06 15:31:59 -06:00
## Example
2015-12-28 21:23:53 +01:00
### ListBuckets()
This example shows how to List your buckets.
2015-11-06 15:31:59 -06:00
```go
package main
import (
"log"
"github.com/minio/minio-go"
)
func main() {
2015-12-28 21:23:53 +01:00
// Requests are always secure (HTTPS) by default. Set insecure=true to enable insecure (HTTP) access.
// This boolean value is the last argument for New().
// New returns an Amazon S3 compatible client object. API copatibality (v2 or v4) is automatically
// determined based on the Endpoint value.
s3Client, err := minio.New("s3.amazonaws.com", "YOUR-ACCESS-KEY-HERE", "YOUR-SECRET-KEY-HERE", false)
2015-11-06 15:31:59 -06:00
if err != nil {
log.Fatalln(err)
}
2015-12-28 21:23:53 +01:00
buckets, err := s3Client.ListBuckets()
if err != nil {
log.Fatalln(err)
}
for _, bucket := range buckets {
log.Println(bucket)
2015-11-06 15:31:59 -06:00
}
}
```
## Documentation
2016-04-18 21:27:13 +02:00
[API documentation ](./API.md )
## Examples
2015-12-28 21:23:53 +01:00
### Bucket Operations.
2016-04-18 21:27:13 +02:00
* [MakeBucket(bucketName, location) error ](examples/s3/makebucket.go )
2015-12-28 21:23:53 +01:00
* [BucketExists(bucketName) error ](examples/s3/bucketexists.go )
* [RemoveBucket(bucketName) error ](examples/s3/removebucket.go )
2016-01-07 20:23:38 +01:00
* [ListBuckets() []BucketInfo](examples/s3/listbuckets.go)
* [ListObjects(bucketName, objectPrefix, recursive, chan<- struct{}) <-chan ObjectInfo ](examples/s3/listobjects.go )
* [ListIncompleteUploads(bucketName, prefix, recursive, chan<- struct{}) <-chan ObjectMultipartInfo ](examples/s3/listincompleteuploads.go )
2015-12-28 21:23:53 +01:00
### Object Operations.
2016-01-27 23:18:23 +01:00
* [PutObject(bucketName, objectName, io.Reader, contentType) error ](examples/s3/putobject.go )
* [GetObject(bucketName, objectName) (*Object, error) ](examples/s3/getobject.go )
2016-01-07 20:23:38 +01:00
* [StatObject(bucketName, objectName) (ObjectInfo, error) ](examples/s3/statobject.go )
2015-12-28 21:23:53 +01:00
* [RemoveObject(bucketName, objectName) error ](examples/s3/removeobject.go )
* [RemoveIncompleteUpload(bucketName, objectName) <-chan error ](examples/s3/removeincompleteupload.go )
### File Object Operations.
* [FPutObject(bucketName, objectName, filePath, contentType) (size, error) ](examples/s3/fputobject.go )
* [FGetObject(bucketName, objectName, filePath) error ](examples/s3/fgetobject.go )
### Presigned Operations.
2016-04-18 21:27:13 +02:00
* [PresignedGetObject(bucketName, objectName, time.Duration, url.Values) (string, error) ](examples/s3/presignedgetobject.go )
2015-12-28 21:23:53 +01:00
* [PresignedPutObject(bucketName, objectName, time.Duration) (string, error) ](examples/s3/presignedputobject.go )
2015-11-06 15:31:59 -06:00
* [PresignedPostPolicy(NewPostPolicy()) (map[string]string, error)](examples/s3/presignedpostpolicy.go)
2016-04-18 21:27:13 +02:00
### Bucket Policy Operations.
* [SetBucketPolicy(bucketName, objectPrefix, BucketPolicy) error ](examples/s3/setbucketpolicy.go )
* [GetBucketPolicy(bucketName, objectPrefix) (BucketPolicy, error) ](examples/s3/getbucketpolicy.go )
* [RemoveBucketPolicy(bucketName, objectPrefix) error ](examples/s3/removebucketpolicy.go )
2015-11-06 15:31:59 -06:00
### API Reference
[](http://godoc.org/github.com/minio/minio-go)
## Contribute
[Contributors Guide ](./CONTRIBUTING.md )
[](https://travis-ci.org/minio/minio-go) [](https://ci.appveyor.com/project/harshavardhana/minio-go)