Skip to content

PinIdea/oss-aliyun-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aliyun SDK for Go language

Build Status GoDoc

Build and Install

go get:

$ go get github.com/PinIdea/oss-aliyun-go

Example

package main

import (
	"log"

	"github.com/PinIdea/oss-aliyun-go"
)

func main() {
	var (
		accessId  = "z6HPq5j2aoqzAcbt"
		accessKey = "cunI67S8o5s5fvA9myvWkAayTUXhuI"
	)

	// region list:
	// HangZhou         = "oss-cn-hangzhou"
	// QingDao          = "oss-cn-qingdao"
	// HangZhouInternal = "oss-cn-hangzhou-internal"
	// QingDaoInternal  = "oss-cn-qingdao-internal"
	// DefaultRegion    = "oss"
	o := oss.New(oss.DefaultRegion, accessId, accessKey)

	// get a bucket instance
	bucket := o.Bucket("pinidea-test")

	// upload
	var data = []byte("this is a test")
	err := bucket.Put("test.txt", data, "text/plain", oss.PublicRead)
	if err != nil {
		panic(err)
	}
	log.Println("success upload object")

	// get object
	text, err := bucket.Get("test.txt")
	if err != nil {
		panic(err)
	}

	log.Println("get object content:", string(text))

	// delete object
	err = bucket.Del("test.txt")
	if err != nil {
		panic(err)
	}
	log.Println("success delete object")
}

License

licensed under the LGPL

About

aliyun SDK for Go language, based on aws s3 SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%