1 # Alibaba Cloud OSS SDK for Go
3 [![GitHub Version](https://badge.fury.io/gh/aliyun%2Faliyun-oss-go-sdk.svg)](https://badge.fury.io/gh/aliyun%2Faliyun-oss-go-sdk)
4 [![Build Status](https://travis-ci.org/aliyun/aliyun-oss-go-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-go-sdk)
5 [![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-go-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-go-sdk?branch=master)
7 ## [README in Chinese](https://github.com/aliyun/aliyun-oss-go-sdk/blob/master/README-CN.md)
10 > - This Go SDK is based on the official APIs of [Alibaba Cloud OSS](http://www.aliyun.com/product/oss/).
11 > - Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring massive capacity, security, a low cost, and high reliability.
12 > - The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
13 > - With this SDK, you can upload, download and manage data on any app anytime and anywhere conveniently.
16 > - Current version: v2.1.6
18 ## Running Environment
22 ### Install the SDK through GitHub
23 > - Run the 'go get github.com/aliyun/aliyun-oss-go-sdk/oss' command to get the remote code package.
24 > - Use 'import "github.com/aliyun/aliyun-oss-go-sdk/oss"' in your code to introduce OSS Go SDK package.
29 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
34 lsRes, err := client.ListBuckets()
39 for _, bucket := range lsRes.Buckets {
40 fmt.Println("Buckets:", bucket.Name)
46 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
51 err = client.CreateBucket("my-bucket")
59 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
64 err = client.DeleteBucket("my-bucket")
72 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
77 bucket, err := client.Bucket("my-bucket")
82 err = bucket.PutObjectFromFile("my-object", "LocalFile")
90 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
95 bucket, err := client.Bucket("my-bucket")
100 err = bucket.GetObjectToFile("my-object", "LocalFile")
108 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
113 bucket, err := client.Bucket("my-bucket")
118 lsRes, err := bucket.ListObjects()
123 for _, object := range lsRes.Objects {
124 fmt.Println("Objects:", object.Key)
130 client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
135 bucket, err := client.Bucket("my-bucket")
140 err = bucket.DeleteObject("my-object")
147 More example projects can be found at 'src\github.com\aliyun\aliyun-oss-go-sdk\sample' under the installation path of the OSS Go SDK (the first path of the GOPATH variable). The directory contains example projects.
148 Or you can refer to the example objects in the sample directory under 'https://github.com/aliyun/aliyun-oss-go-sdk'.
151 > - Copy the example file. Go to the installation path of OSS Go SDK (the first path of the GOPATH variable), enter the code directory of the OSS Go SDK, namely 'src\github.com\aliyun\aliyun-oss-go-sdk',
152 and copy the sample directory and sample.go to the src directory of your test project.
153 > - Modify the endpoint, AccessKeyId, AccessKeySecret and BucketName configuration settings in sample/config.go.
154 > - Run 'go run src/sample.go' under your project directory.
157 > - [Alibaba Cloud OSS official website](http://oss.aliyun.com).
158 > - [Alibaba Cloud OSS official forum](http://bbs.aliyun.com).
159 > - [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs).
160 > - Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex).
163 > - [Yubin Bai](https://github.com/baiyubin)
164 > - [Guozhong Han](https://github.com/hangzws)
167 > - MIT License, see [license file](LICENSE)