Access Storage with AWS S3 SDKs
Introduction
Install the SDK
npm install aws-sdkgo get -u github.com/aws/aws-sdk-gophp composer.phar require aws/aws-sdk-phppip install boto3gem install aws-sdk-s3Obtain Access & Secret Keys
SDKs
const AWS = require('aws-sdk');
const fs = require('fs'); // Needed for example below
const spacesEndpoint = new AWS.Endpoint('<S3-ENDPOINT>');
const s3 = new AWS.S3({
endpoint: spacesEndpoint,
accessKeyId: process.env.ACCESS_KEY,
secretAccessKey: process.env.SECRET_KEY
});package main
import (
"os"
// Additional imports needed for examples below
"fmt"
"io"
"strings"
"time"
"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() {
key := os.Getenv("ACCESS_KEY")
secret := os.Getenv("SECRET_KEY")
s3Config := &aws.Config{
Credentials: credentials.NewStaticCredentials(key, secret, ""),
Endpoint: aws.String("https://<ENDPOINT>"),
Region: aws.String("us-east-1"),
}
newSession := session.New(s3Config)
s3Client := s3.New(newSession)
// ...Last updated