Documentation Index
Fetch the complete documentation index at: https://docs.tenbyte.io/llms.txt
Use this file to discover all available pages before exploring further.
How do I use the AWS SDK for Go with Tenbyte T2?
You can take advantage of Tenbyte T2 Cloud Storage using the AWS SDK for Go alongside the Tenbyte S3-Compatible API.
It is easy to use the AWS Go SDK to integrate object storage into your Go environment.
The following example shows a configuration of the AWS Go SDK with the Tenbyte S3-Compatible API.
Note: Make sure to replace <T2-keyId> and <T2-appKey> with your actual Tenbyte T2 Access Key ID and Secret Access Key from your Tenbyte console.
package main
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
bucket := aws.String("my-tenbyte-bucket")
key := aws.String("sample.txt")
// Configure the S3 client to point to Tenbyte T2
s3Config := &aws.Config{
Credentials: credentials.NewStaticCredentials("<T2-keyId>", "<T2-appKey>", ""),
Endpoint: aws.String("https://t2.tenbytecloud.com"),
Region: aws.String("us-east-1"),
S3ForcePathStyle: aws.Bool(true),
}
newSession := session.New(s3Config)
s3Client := s3.New(newSession)
// Create a new bucket
cparams := &s3.CreateBucketInput{
Bucket: bucket, // Required
}
_, err := s3Client.CreateBucket(cparams)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Printf("Successfully created bucket %s\n", *bucket)
// Upload a new object "sample.txt" with the string "S3 Compatible API"
_, err = s3Client.PutObject(&s3.PutObjectInput{
Body: strings.NewReader("S3 Compatible API"),
Bucket: bucket,
Key: key,
})
if err != nil {
fmt.Printf("Failed to upload object %s/%s, %s\n", *bucket, *key, err.Error())
return
}
fmt.Printf("Successfully uploaded key %s\n", *key)
// Get Object
_, err = s3Client.GetObject(&s3.GetObjectInput{
Bucket: bucket,
Key: key,
})
if err != nil {
fmt.Println("Failed to download file", err)
return
}
fmt.Printf("Successfully downloaded key %s\n", *key)
}
The S3-Compatible API allows thousands of integrations to natively work with Tenbyte T2 Cloud Storage. If you are new to the Tenbyte S3-Compatible API, refer to the Getting Started guide.
If you have issues using this SDK with Tenbyte T2, contact us at support@tenbyte.io.