minio

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2015 License: Apache-2.0 Imports: 22 Imported by: 0

README

Minio Go Library for Amazon S3 Compatible Cloud Storage Gitter

Install Build Status

$ go get github.com/minio/minio-go

Example

package main

import (
	"log"

	"github.com/minio/minio-go"
)

func main() {
	config := minio.Config{
		AccessKeyID:     "YOUR-ACCESS-KEY-HERE",
		SecretAccessKey: "YOUR-PASSWORD-HERE",
		Endpoint:        "https://s3.amazonaws.com",
	}
	s3Client, err := minio.New(config)
	if err != nil {
	    log.Fatalln(err)
	}
	for bucket := range s3Client.ListBuckets() {
		if bucket.Err != nil {
			log.Fatalln(bucket.Err)
		}
		log.Println(bucket.Stat)
	}
}

Documentation

Bucket Level
Object Level
API Reference

GoDoc

Contribute

Contributors Guide

Documentation

Index

Constants

View Source
const (
	LibraryName    = "minio-go"
	LibraryVersion = "0.2.2"
)

Global constants

Variables

This section is empty.

Functions

func BodyToErrorResponse added in v0.2.1

func BodyToErrorResponse(errBody io.Reader, acceptType string) error

BodyToErrorResponse returns a new encoded ErrorResponse structure

Types

type API

type API interface {
	// Bucket Read/Write/Stat operations
	BucketAPI

	// Object Read/Write/Stat operations
	ObjectAPI

	// Presigned API
	PresignedAPI
}

API - Cloud Storage API interface

func New

func New(config Config) (API, error)

New - instantiate a new minio api client

type BucketACL

type BucketACL string

BucketACL - bucket level access control

func (BucketACL) String

func (b BucketACL) String() string

String printer helper

type BucketAPI

type BucketAPI interface {
	MakeBucket(bucket string, cannedACL BucketACL) error
	BucketExists(bucket string) error
	RemoveBucket(bucket string) error
	SetBucketACL(bucket string, cannedACL BucketACL) error
	GetBucketACL(bucket string) (BucketACL, error)

	ListBuckets() <-chan BucketStatCh
	ListObjects(bucket, prefix string, recursive bool) <-chan ObjectStatCh

	// Drop all incomplete uploads
	DropAllIncompleteUploads(bucket string) <-chan error
}

BucketAPI - bucket specific Read/Write/Stat interface

type BucketStat

type BucketStat struct {
	// The name of the bucket.
	Name string
	// Date the bucket was created.
	CreationDate time.Time
}

BucketStat container for bucket metadata

type BucketStatCh

type BucketStatCh struct {
	Stat BucketStat
	Err  error
}

BucketStatCh - bucket metadata over read channel

type Config

type Config struct {
	// Standard options
	AccessKeyID     string
	SecretAccessKey string
	Endpoint        string

	// Advanced options
	// Specify this to get server response in non XML style if server supports it
	AcceptType string
	// Optional field. If empty, region is determined automatically.
	Region string

	// Expert options
	//
	// Set this to override default transport “http.DefaultTransport“
	//
	// This transport is usually needed for debugging OR to add your own
	// custom TLS certificates on the client transport, for custom CA's and
	// certs which are not part of standard certificate authority
	//
	// For example :-
	//
	//  tr := &http.Transport{
	//          TLSClientConfig:    &tls.Config{RootCAs: pool},
	//          DisableCompression: true,
	//  }
	//
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

Config - main configuration struct used by all to set endpoint, credentials, and other options for requests.

func (*Config) SetUserAgent

func (c *Config) SetUserAgent(name string, version string, comments ...string)

SetUserAgent - append to a default user agent

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name `xml:"Error" json:"-"`
	Code      string
	Message   string
	Resource  string
	RequestID string `xml:"RequestId"`
	HostID    string `xml:"HostId"`
}

ErrorResponse is the type error returned by some API operations.

func ToErrorResponse

func ToErrorResponse(err error) *ErrorResponse

ToErrorResponse returns parsed ErrorResponse struct, if input is nil or not ErrorResponse return value is nil this fuction is useful when some one wants to dig deeper into the error structures over the network.

for example:

import s3 "github.com/minio/minio-go"
...
...
..., err := s3.GetObject(...)
if err != nil {
   resp := s3.ToErrorResponse(err)
   fmt.Println(resp.ToXML())
}
...
...

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

Error formats HTTP error string

func (ErrorResponse) ToJSON

func (e ErrorResponse) ToJSON() string

ToJSON send raw json marshalled as string

func (ErrorResponse) ToXML

func (e ErrorResponse) ToXML() string

ToXML send raw xml marshalled as string

type ObjectAPI

type ObjectAPI interface {
	GetObject(bucket, object string) (io.ReadCloser, ObjectStat, error)
	GetPartialObject(bucket, object string, offset, length int64) (io.ReadCloser, ObjectStat, error)
	PutObject(bucket, object, contentType string, size int64, data io.Reader) error
	StatObject(bucket, object string) (ObjectStat, error)
	RemoveObject(bucket, object string) error

	// Drop all incomplete uploads for a given object
	DropIncompleteUpload(bucket, object string) <-chan error
}

ObjectAPI - object specific Read/Write/Stat interface

type ObjectStat

type ObjectStat struct {
	ETag         string
	Key          string
	LastModified time.Time
	Size         int64
	ContentType  string

	Owner struct {
		DisplayName string
		ID          string
	}

	// The class of storage used to store the object.
	StorageClass string
}

ObjectStat container for object metadata

type ObjectStatCh

type ObjectStatCh struct {
	Stat ObjectStat
	Err  error
}

ObjectStatCh - object metadata over read channel

type PresignedAPI added in v0.2.1

type PresignedAPI interface {
	PresignedGetObject(bucket, object string, expires time.Duration) (string, error)
	PresignedGetPartialObject(bucket, object string, expires time.Duration, offset, length int64) (string, error)
}

PresignedAPI - object specific for now

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL