Client SDKs
Client SDKs
Section titled “Client SDKs”Stowry provides official SDKs for Go, Python, and JavaScript. All SDKs implement Stowry’s native signing scheme for generating presigned URLs.
For AWS SDK compatibility, see Using AWS SDKs below.
Official SDKs
Section titled “Official SDKs”| SDK | Package | Repository |
|---|---|---|
| Go | github.com/sagarc03/stowry-go | stowry-go |
| Python | stowrypy | stowrypy |
| JavaScript | stowryjs | stowryjs |
Installation
Section titled “Installation”go get github.com/sagarc03/stowry-gopip install stowrypynpm install stowryjsQuick Start
Section titled “Quick Start”package main
import ( "bytes" "fmt" "io" "net/http" "time"
stowry "github.com/sagarc03/stowry-go")
func main() { client := stowry.NewClient( "http://localhost:5708", "YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", )
httpClient := &http.Client{Timeout: 30 * time.Second}
// Upload putURL := client.PresignPut("/hello.txt", 900) req, _ := http.NewRequest("PUT", putURL, bytes.NewReader([]byte("Hello!"))) req.Header.Set("Content-Type", "text/plain") httpClient.Do(req)
// Download getURL := client.PresignGet("/hello.txt", 900) resp, _ := httpClient.Get(getURL) defer resp.Body.Close() content, _ := io.ReadAll(resp.Body) fmt.Println(string(content))
// Delete deleteURL := client.PresignDelete("/hello.txt", 300) req, _ = http.NewRequest("DELETE", deleteURL, nil) httpClient.Do(req)}import requestsfrom stowrypy import StowryClient
client = StowryClient( endpoint="http://localhost:5708", access_key="YOUR_ACCESS_KEY", secret_key="YOUR_SECRET_KEY",)
# Uploadput_url = client.presign_put("/hello.txt", expires=900)requests.put(put_url, data=b"Hello!", headers={"Content-Type": "text/plain"})
# Downloadget_url = client.presign_get("/hello.txt", expires=900)response = requests.get(get_url)print(response.text)
# Deletedelete_url = client.presign_delete("/hello.txt", expires=300)requests.delete(delete_url)import { StowryClient } from 'stowryjs';
const client = new StowryClient({ endpoint: 'http://localhost:5708', accessKey: 'YOUR_ACCESS_KEY', secretKey: 'YOUR_SECRET_KEY',});
// Uploadconst putUrl = await client.presignPut('/hello.txt', 900);await fetch(putUrl, { method: 'PUT', body: 'Hello!', headers: { 'Content-Type': 'text/plain' },});
// Downloadconst getUrl = await client.presignGet('/hello.txt', 900);const response = await fetch(getUrl);console.log(await response.text());
// Deleteconst deleteUrl = await client.presignDelete('/hello.txt', 300);await fetch(deleteUrl, { method: 'DELETE' });API Reference
Section titled “API Reference”All SDKs share the same API design:
Constructor
Section titled “Constructor”| Language | Constructor |
|---|---|
| Go | stowry.NewClient(endpoint, accessKey, secretKey) |
| Python | StowryClient(endpoint, access_key, secret_key) |
| JavaScript | new StowryClient({ endpoint, accessKey, secretKey }) |
Methods
Section titled “Methods”| Method | Parameters | Returns | Description |
|---|---|---|---|
PresignGet / presign_get / presignGet | path, expires | URL string | Generate download URL |
PresignPut / presign_put / presignPut | path, expires | URL string | Generate upload URL |
PresignDelete / presign_delete / presignDelete | path, expires | URL string | Generate delete URL |
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | - | Object path (must start with /) |
expires | int | 900 | URL validity in seconds (max: 604800 / 7 days) |
Using AWS SDKs
Section titled “Using AWS SDKs”Stowry also supports AWS Signature V4, so you can use AWS SDKs to generate presigned URLs.
import ( "context" "time"
"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 createPresignClient() (*s3.PresignClient, error) { cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-east-1"), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider( "YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", "", )), ) if err != nil { return nil, err }
client := s3.NewFromConfig(cfg, func(o *s3.Options) { o.BaseEndpoint = aws.String("http://localhost:5708") o.UsePathStyle = true // Required })
return s3.NewPresignClient(client), nil}
// Usageclient, _ := createPresignClient()resp, _ := client.PresignGetObject(context.Background(), &s3.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("hello.txt"), }, s3.WithPresignExpires(15*time.Minute),)fmt.Println(resp.URL)import boto3from botocore.config import Config
s3 = boto3.client( 's3', endpoint_url='http://localhost:5708', aws_access_key_id='YOUR_ACCESS_KEY', aws_secret_access_key='YOUR_SECRET_KEY', region_name='us-east-1', config=Config(s3={'addressing_style': 'path'}) # Required)
# Generate presigned URLurl = s3.generate_presigned_url( 'get_object', Params={'Bucket': 'bucket', 'Key': 'hello.txt'}, ExpiresIn=900)import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
const client = new S3Client({ endpoint: 'http://localhost:5708', region: 'us-east-1', credentials: { accessKeyId: 'YOUR_ACCESS_KEY', secretAccessKey: 'YOUR_SECRET_KEY', }, forcePathStyle: true, // Required});
const url = await getSignedUrl( client, new GetObjectCommand({ Bucket: 'bucket', Key: 'hello.txt' }), { expiresIn: 900 });Native vs AWS SDK
Section titled “Native vs AWS SDK”| Feature | Native SDK | AWS SDK |
|---|---|---|
| Setup complexity | Simple | More configuration |
| Dependencies | Minimal | AWS SDK packages |
| Signing scheme | Stowry native | AWS Signature V4 |
| Async (JS) | Yes | Yes |
| Browser support | Yes (stowryjs) | Yes |
When to use Native SDKs:
- New projects
- Minimal dependencies preferred
- Simple integration
When to use AWS SDKs:
- Existing AWS SDK usage in codebase
- Team familiarity with AWS patterns
- Multi-cloud compatibility needs
Browser Usage
Section titled “Browser Usage”Both stowryjs and AWS SDK v3 work in browsers. Generate presigned URLs server-side for security:
// Server (Node.js/Bun/Deno)import { StowryClient } from 'stowryjs';
const client = new StowryClient({ endpoint: process.env.STOWRY_ENDPOINT, accessKey: process.env.STOWRY_ACCESS_KEY, secretKey: process.env.STOWRY_SECRET_KEY,});
app.get('/api/upload-url', async (req, res) => { const { filename } = req.query; const url = await client.presignPut(`/uploads/${filename}`, 300); res.json({ url });});
// Client (Browser)async function uploadFile(file) { const { url } = await fetch(`/api/upload-url?filename=${file.name}`) .then(r => r.json());
await fetch(url, { method: 'PUT', body: file, headers: { 'Content-Type': file.type }, });}Platform Support
Section titled “Platform Support”stowry-go
Section titled “stowry-go”- Go 1.21+
stowrypy
Section titled “stowrypy”- Python 3.8+
- No external dependencies (uses stdlib only)
stowryjs
Section titled “stowryjs”- Node.js 18+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Deno and Bun compatible
- Uses Web Crypto API (browser) or Node.js crypto