doclient

package module
v0.0.0-...-bd991f8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 8 Imported by: 0

README

Digital Ocean Client

Digital Ocean client designed for easy use. It's used by my own DongFeng project.

Dependencies

  • Minio-Go Client SDK for Amazon S3 Compatible Cloud Storage

Object Upload

example:

import github.com/ilovelili/digital-ocean-client

func main() {
    spaceservice := doclient.NewSpaceService("<<api key>>", "<<secret key>>")
    spaceservice.SetRegion("sgp1")
    spaceservice.SetEndPoint("sgp1.digitaloceanspaces.com")
    spaceservice.SetBucket("dongfeng")

    opts := &doclient.UploadOptions{
        FileName: "./test.png",
        Public:   true,
    }

    resp := spaceservice.Upload(opts)
    if resp.Error != nil {
        log.Fatal(err)
    }
}

Contact

route666@live.cn

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SpaceContext

type SpaceContext struct {
	EndPoint string
	Region   string
	Bucket   string
}

SpaceContext context includes EndPoint, Region and FileName info

type SpaceService

type SpaceService struct {
	Context      *SpaceContext
	AccessKey    string
	AccessSecret string
}

SpaceService service defines context

func NewSpaceService

func NewSpaceService(key, secret string) *SpaceService

NewSpaceService service initializer

func (*SpaceService) AsyncUpload

func (ss *SpaceService) AsyncUpload(opts *UploadOptions) (errchan chan<- *UploadResponse)

AsyncUpload async upload

func (*SpaceService) GetBucket

func (ss *SpaceService) GetBucket() string

GetBucket get bucket

func (*SpaceService) GetEndPoint

func (ss *SpaceService) GetEndPoint() string

GetEndPoint get endpoint

func (*SpaceService) GetRegion

func (ss *SpaceService) GetRegion() string

GetRegion get region

func (*SpaceService) SetBucket

func (ss *SpaceService) SetBucket(bucket string)

SetBucket set bucket

func (*SpaceService) SetEndPoint

func (ss *SpaceService) SetEndPoint(endpoint string)

SetEndPoint set endpoint

func (*SpaceService) SetRegion

func (ss *SpaceService) SetRegion(region string)

SetRegion set region

func (*SpaceService) Upload

func (ss *SpaceService) Upload(opts *UploadOptions) (resp *UploadResponse)

Upload upload file

type UploadOptions

type UploadOptions struct {
	FileName string
	// visible to public or not
	Public bool
	// Timeout upload timeout
	Timeout time.Duration
	// Metadata user metadata
	Metadata map[string]string
}

UploadOptions upload response

type UploadResponse

type UploadResponse struct {
	// Location location of uploaded file
	Location string
	Error    error
}

UploadResponse upload response

Jump to

Keyboard shortcuts

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