Skip to content

cz-theng/aliyun-oss-golang-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#aliyun-oss-golang-sdk Build Status Coverage Status linthub

Aliyun OSS Golang SDK is a wrap for Aliyun OSS Web API on Golang. To use this SDK you should install golang first, see how to install golang .The following articles assume that golang has been installed.

Use go get commands to get Aliyun OSS Golang SDK and it's command tools "osscmd".

go get github.com/cz-it/aliyun-oss-golang-sdk/ossapi
go get github.com/cz-it/aliyun-oss-golang-sdk/osscmd

After installed SDK and command tool ,you can use command

osscmd -v 

To test if installed success.

Or you can import github.com/cz-it/aliyun-oss-golang-sdk/ossapi and invoke the Version() fucntion .

package main

import (
	"fmt"
	"github.com/cz-it/aliyun-oss-golang-sdk/ossapi"
) 

func main() {
	fmt.Println(ossapi.Version())
}

After testing installed successful.You can use API like demo this.

package main

import (
	"fmt"
	"github.com/cz-it/aliyun-oss-golang-sdk/ossapi"
	"github.com/cz-it/aliyun-oss-golang-sdk/ossapi/service"
)

func main () {
	err := ossapi.Init("v8P430U3UcILP", "EB9v8yL2aM07YOgtO1BdfrXtdxa4")
	if err != nil {
		fmt.Println(err.Error())
		return 
	}
	
	info, e := service.GetServiceDefault()
	if e != nil {
		fmt.Println(e.Error())
		return
	}
	fmt.Println("Owner:", info.Owner.DisplayName)
	for idx, bucket := range info.Buckets.Bucket {
		fmt.Printf("	Bucket[%v]:", idx)
		fmt.Println(bucket)
	}
}

Use go run may get output like this:

Owner: 1415982622007927
	Bucket[0]:{python-sdk-test 2015-10-21T12:31:32.000Z oss-cn-hangzhou}
	Bucket[1]:{python-sdk-test2 2015-10-21T12:31:50.000Z oss-cn-hangzhou}
	Bucket[2]:{test-cors 2015-10-27T17:38:40.000Z oss-cn-hangzhou}

Here use "Init" with your Access Key ID and Access Secret to init ossapi. Then use "GetServiceDefault" to list all your buckets.

What Next?

API Referece

Also Godoc

About

sdk for aliyun's oss with golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published