minio

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2015 License: Apache-2.0 Imports: 21 Imported by: 0

README

Minimal object storage library in Go 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.0"
)

Global constants

Variables

This section is empty.

Functions

This section is empty.

Types

type API added in v0.1.0

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

	// Object Read/Write/Stat operations
	ObjectAPI
}

API - object storage API interface

func New

func New(config Config) (API, error)

New - instantiate a new minio api client

type BucketACL added in v0.1.0

type BucketACL string

BucketACL - bucket level access control

func (BucketACL) String added in v0.1.0

func (b BucketACL) String() string

String printer helper

type BucketAPI added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

type BucketStatCh struct {
	Stat BucketStat
	Err  error
}

BucketStatCh - bucket metadata over read channel

type Config added in v0.1.0

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 added in v0.1.0

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 added in v0.1.0

func (e ErrorResponse) ToJSON() string

JSON send raw json marshalled as string

func (ErrorResponse) ToXML added in v0.1.0

func (e ErrorResponse) ToXML() string

XML send raw xml marshalled as string

type ObjectAPI added in v0.1.0

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
	DropIncompleteUploads(bucket, object string) <-chan error
}

ObjectAPI - object specific Read/Write/Stat interface

type ObjectStat added in v0.1.0

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 added in v0.1.0

type ObjectStatCh struct {
	Stat ObjectStat
	Err  error
}

ObjectStatCh - object metadata over read channel

Jump to

Keyboard shortcuts

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