Skip to content

s3util is an easy way to interact with S3 or S3-compatible storage.

Notifications You must be signed in to change notification settings

LawyZheng/s3util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3util

s3util is an easy way to interact with S3 or S3-compatible storage.

Installation

go get github.com/lawyzheng/s3util

Quick Start

  • Create Client

client := s3util.NewS3Client("my_endpoint", "my_accesskey", "my_scretekey")
  • Create Bucket

err := client.CreateBucket("my-bucket")
if err != nil {
    // handler error
    ...
}
  • Get Object Download URL

urlString, err := client.GetObjectDownloadURL("my-bucket", "my_key", time.Minute)
if err != nil {
    // handler error
    ...
}
  • Upload Object From HTTP Response

resp, err := http.Get("my_resource_url")
if err != nil {
    // handler error
    ...
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
    // handler status code which is not 200
    ...
}

// skip will be true, if the object have already existed.
skip, err := client.UploadHttpResponse("my-bucket", "my_key", resp)
if err != nil {
    // handle error
    ...
}

About

s3util is an easy way to interact with S3 or S3-compatible storage.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages