aliyun/aliyun-oss-go-sdk
Fork: 232 Star: 955 (更新于 2024-12-18 09:17:03)
license: MIT
Language: Go .
Aliyun OSS SDK for Go
最后发布版本: v3.0.2 ( 2023-12-28 20:42:07)
Alibaba Cloud OSS SDK for Go
README in Chinese
About OSS SDK for Go V2
- OSS SDK for Go V2(alibabacloud-oss-go-sdk-v2) has been released, it is a major rewrite of OSS SDK for Go V1 (aliyun-oss-go-sdk).
- V2 simplifies underlying operations such as identification authentication, automatic retry of failed requests, and error handling. It provides flexible parameter configuration methods and rich advanced operations, such as paginator, transmission managers, and File-like operations. This comprehensively improves development efficiency and experience.
- How to get started with V2, visit Developer Guide.
- How to migrate to V2, visit Migration Guide.
About
- This Go SDK is based on the official APIs of Alibaba Cloud OSS.
- 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.
- The OSS can store any type of files and therefore applies to various websites, development enterprises and developers.
- With this SDK, you can upload, download and manage data on any app anytime and anywhere conveniently.
Version
- Current version: v3.0.2
Running Environment
- Go 1.5 or above.
Installing
Install the SDK through GitHub
- Run the 'go get github.com/aliyun/aliyun-oss-go-sdk' command to get the remote code package.
- Use 'import "github.com/aliyun/aliyun-oss-go-sdk/oss"' in your code to introduce OSS Go SDK package.
Getting Started
List Bucket
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
lsRes, err := client.ListBuckets()
if err != nil {
// HandleError(err)
}
for _, bucket := range lsRes.Buckets {
fmt.Println("Buckets:", bucket.Name)
}
Create Bucket
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
err = client.CreateBucket("my-bucket")
if err != nil {
// HandleError(err)
}
Delete Bucket
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
err = client.DeleteBucket("my-bucket")
if err != nil {
// HandleError(err)
}
Put Object
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
bucket, err := client.Bucket("my-bucket")
if err != nil {
// HandleError(err)
}
err = bucket.PutObjectFromFile("my-object", "LocalFile")
if err != nil {
// HandleError(err)
}
Get Object
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
bucket, err := client.Bucket("my-bucket")
if err != nil {
// HandleError(err)
}
err = bucket.GetObjectToFile("my-object", "LocalFile")
if err != nil {
// HandleError(err)
}
List Objects
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
bucket, err := client.Bucket("my-bucket")
if err != nil {
// HandleError(err)
}
lsRes, err := bucket.ListObjects()
if err != nil {
// HandleError(err)
}
for _, object := range lsRes.Objects {
fmt.Println("Objects:", object.Key)
}
Delete Object
client, err := oss.New("Endpoint", "AccessKeyId", "AccessKeySecret")
if err != nil {
// HandleError(err)
}
bucket, err := client.Bucket("my-bucket")
if err != nil {
// HandleError(err)
}
err = bucket.DeleteObject("my-object")
if err != nil {
// HandleError(err)
}
Complete Example
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. Or you can refer to the example objects in the sample directory under 'https://github.com/aliyun/aliyun-oss-go-sdk'.
Running Example
- 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', and copy the sample directory and sample.go to the src directory of your test project.
- Modify the endpoint, AccessKeyId, AccessKeySecret and BucketName configuration settings in sample/config.go.
- Run 'go run src/sample.go' under your project directory.
Contacting us
- Alibaba Cloud OSS official website.
- Alibaba Cloud OSS official forum.
- Alibaba Cloud OSS official documentation center.
- Alibaba Cloud official technical support: Submit a ticket.
Author
License
- MIT License, see license file
最近版本更新:(数据更新于 2024-09-15 00:55:05)
2023-12-28 20:42:07 v3.0.2
2023-11-01 18:20:13 v3.0.1
2023-10-30 12:08:23 v2.2.10
2023-08-25 11:48:02 v2.2.9
2023-07-31 16:47:52 v2.2.8
2023-03-23 16:53:08 v2.2.7
2022-11-16 16:21:23 v2.2.6
2022-08-22 13:45:02 v2.2.5
2022-05-25 11:31:58 v2.2.4
2022-05-13 16:43:53 v2.2.3
aliyun/aliyun-oss-go-sdk同语言 Go最近更新仓库
2024-12-22 07:52:58 navidrome/navidrome
2024-12-21 20:15:12 SagerNet/sing-box
2024-12-21 03:25:54 SpecterOps/BloodHound
2024-12-19 23:11:24 shadow1ng/fscan
2024-12-19 21:50:56 minio/minio
2024-12-19 10:04:39 istio/istio