(checked SDK version aws-sdk-go :: v0.6.6
Simple wrapper for aws-sdk-go At this time, it suports services below,
DynamoDB
S3
SQS
SNS
vim aws.json
{
"access_key": "XXXXXXXXXXXXXXXXXXXX",
"secret_key": "abcdefg",
}
import (
"github.com/cnry/aws-sdk-go-wrapper/dynamodb"
)
func main() {
// Create connection client
cli := ddb.NewClient()
// Get dynamodb table
table, err := cli.GetTable("MyDynamoTable")
if err != nil {
panic("error on loading dynamodb table")
}
// Create new dynamodb item (row on RDBMS)
item := dynamodb.NewItem()
item.AddAttribute("user_id", 999)
item.AddAttribute("status", 1)
// Add item to the wait list.
table.AddItem(item)
item2 := dynamodb.NewItem()
item.AddAttribute("user_id", 1000)
item.AddAttribute("status", 2)
item.AddConditionEQ("status", 3) // Add condition for write
table.AddItem(item2)
// write all
cli.PutAll()
}
import(
"os"
// import this
"github.com/cnry/aws-sdk-go-wrapper/s3"
)
func main(){
cli := s3.NewClient()
bucket := cli.GetBucket("MyBucket")
// upload file
var file *os.File
file = getFile() // dummy code. this expects return data of "*os.File", like from POST form.
s3obj := s3.NewS3Object(file)
bucket.AddObject(s3obj, "/foo/bar/new_file")
bucket.Put()
// upload file from text data
text := "Lorem ipsum"
s3obj2 := s3.NewS3ObjectString(text)
bucket.AddObject(s3obj2, "/log/new_text.txt")
// upload file of ACL authenticated-read
bucket.AddSecretObject(s3obj2, "/secret_path/new_secret_file.txt")
// put all added objects.
bucket.Put() // upload "/log/new_text.txt" & "/secret_path/new_secret_file.txt"
}
Apache License, Version 2.0