---
title: "SDK examples"
description: "Code examples for connecting AWS S3 SDKs to Edge Network storage in JavaScript, Python, Go, and Ruby, covering setup, uploads, downloads, and object listing."
url: "https://edge.network/docs/storage/sdk-examples"
section: "Storage"
---

# SDK examples

Edge Storage is fully compatible with AWS S3 SDKs. Use the official AWS SDK for your language with our endpoint.

The examples below use the official AWS SDKs for JavaScript and TypeScript, Python, Go and Ruby. Pick your language in each code block.

## Install the SDK

```bash tab="JavaScript"
npm install @aws-sdk/client-s3
```

```bash tab="Python"
pip install boto3
```

```bash tab="Go"
go get github.com/aws/aws-sdk-go-v2
go get github.com/aws/aws-sdk-go-v2/service/s3
go get github.com/aws/aws-sdk-go-v2/credentials
```

```bash tab="Ruby"
gem install aws-sdk-s3
```

## Set up the client

```js tab="JavaScript"
import {
  S3Client,
  PutObjectCommand,
  GetObjectCommand,
  ListObjectsV2Command
} from '@aws-sdk/client-s3'

const client = new S3Client({
  endpoint: 'https://storage.edge.network',
  region: 'us-east-1',
  forcePathStyle: true,
  credentials: {
    accessKeyId: process.env.EDGE_ACCESS_KEY,
    secretAccessKey: process.env.EDGE_SECRET_KEY
  }
})
```

```python tab="Python"
import boto3
import os

client = boto3.client(
    's3',
    endpoint_url='https://storage.edge.network',
    aws_access_key_id=os.environ['EDGE_ACCESS_KEY'],
    aws_secret_access_key=os.environ['EDGE_SECRET_KEY'],
    region_name='us-east-1'
)
```

```go tab="Go"
package main

import (
    "context"
    "os"

    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/credentials"
    "github.com/aws/aws-sdk-go-v2/service/s3"
)

func main() {
    cfg, _ := config.LoadDefaultConfig(context.TODO(),
        config.WithRegion("us-east-1"),
        config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
            os.Getenv("EDGE_ACCESS_KEY"),
            os.Getenv("EDGE_SECRET_KEY"),
            "",
        )),
    )

    client := s3.NewFromConfig(cfg, func(o *s3.Options) {
        o.BaseEndpoint = aws.String("https://storage.edge.network")
        o.UsePathStyle = true
    })
}
```

```ruby tab="Ruby"
require 'aws-sdk-s3'

client = Aws::S3::Client.new(
  endpoint: 'https://storage.edge.network',
  region: 'us-east-1',
  force_path_style: true,
  access_key_id: ENV['EDGE_ACCESS_KEY'],
  secret_access_key: ENV['EDGE_SECRET_KEY']
)
```

## Upload an object

```js tab="JavaScript"
await client.send(new PutObjectCommand({
  Bucket: 'my-bucket',
  Key: 'images/photo.jpg',
  Body: fileBuffer,
  ContentType: 'image/jpeg'
}))
```

```python tab="Python"
# Upload a file
client.upload_file('local-file.txt', 'my-bucket', 'remote-file.txt')

# Or upload bytes directly
client.put_object(
    Bucket='my-bucket',
    Key='hello.txt',
    Body=b'Hello, Edge Storage!'
)
```

```go tab="Go"
_, err := client.PutObject(context.TODO(), &s3.PutObjectInput{
    Bucket: aws.String("my-bucket"),
    Key:    aws.String("hello.txt"),
    Body:   strings.NewReader("Hello, Edge Storage!"),
})
```

```ruby tab="Ruby"
client.put_object(
  bucket: 'my-bucket',
  key: 'hello.txt',
  body: 'Hello, Edge Storage!'
)
```

## Download an object

```js tab="JavaScript"
const response = await client.send(new GetObjectCommand({
  Bucket: 'my-bucket',
  Key: 'images/photo.jpg'
}))

const body = await response.Body.transformToByteArray()
```

```python tab="Python"
# Download to file
client.download_file('my-bucket', 'remote-file.txt', 'local-file.txt')

# Or get bytes
response = client.get_object(Bucket='my-bucket', Key='hello.txt')
data = response['Body'].read()
```

```ruby tab="Ruby"
response = client.get_object(bucket: 'my-bucket', key: 'hello.txt')
puts response.body.read
```

## List objects

```js tab="JavaScript"
const response = await client.send(new ListObjectsV2Command({
  Bucket: 'my-bucket',
  Prefix: 'images/'
}))

for (const obj of response.Contents || []) {
  console.log(obj.Key, obj.Size)
}
```

```python tab="Python"
response = client.list_objects_v2(
    Bucket='my-bucket',
    Prefix='images/'
)

for obj in response.get('Contents', []):
    print(obj['Key'], obj['Size'])
```

## Common configuration

Whichever SDK you use, you'll need these settings:

| Setting | Value | Notes |
|---|---|---|
| `endpoint` | `https://storage.edge.network` | Required |
| `region` | `us-east-1` | Use any valid region string |
| `forcePathStyle` | `true` | Required for Edge Storage |
