Skip to content

sagarc03/stowrypy

Repository files navigation

stowrypy

PyPI version Python versions CI codecov License: MIT

A Python SDK for generating Stowry presigned URLs.

Installation

pip install stowrypy

Quick Start

from stowrypy import StowryClient

client = StowryClient(
    endpoint="http://localhost:5708",
    access_key="your-access-key",
    secret_key="your-secret-key",
)

# Generate a presigned URL for downloading a file
get_url = client.presign_get("/files/document.pdf")

# Generate a presigned URL for uploading a file
put_url = client.presign_put("/files/upload.txt")

# Generate a presigned URL for deleting a file
delete_url = client.presign_delete("/files/old.txt")

Usage with HTTP Clients

import requests
from stowrypy import StowryClient

client = StowryClient(
    endpoint="http://localhost:5708",
    access_key="your-access-key",
    secret_key="your-secret-key",
)

# Download a file
get_url = client.presign_get("/files/document.pdf")
response = requests.get(get_url)
content = response.content

# Upload a file
put_url = client.presign_put("/files/upload.txt")
requests.put(put_url, data=b"Hello, World!")

# Delete a file
delete_url = client.presign_delete("/files/old.txt")
requests.delete(delete_url)

API Reference

StowryClient

StowryClient(endpoint: str, access_key: str, secret_key: str)

Creates a new Stowry client.

Parameter Type Description
endpoint str Stowry server URL (e.g., http://localhost:5708)
access_key str Access key ID
secret_key str Secret access key

Methods

presign_get

presign_get(path: str, expires: int = 900) -> str

Generates a presigned URL for GET requests.

Parameter Type Default Description
path str - Object path (must start with /)
expires int 900 URL validity in seconds (1-604800)

presign_put

presign_put(path: str, expires: int = 900) -> str

Generates a presigned URL for PUT requests.

Parameter Type Default Description
path str - Object path (must start with /)
expires int 900 URL validity in seconds (1-604800)

presign_delete

presign_delete(path: str, expires: int = 900) -> str

Generates a presigned URL for DELETE requests.

Parameter Type Default Description
path str - Object path (must start with /)
expires int 900 URL validity in seconds (1-604800)

generate_presigned_url

generate_presigned_url(operation: str, path: str, expires: int = 900) -> str

S3-compatible interface for generating presigned URLs.

Parameter Type Default Description
operation str - get_object, put_object, or delete_object
path str - Object path (must start with /)
expires int 900 URL validity in seconds (1-604800)

URL Expiration

  • Default: 900 seconds (15 minutes)
  • Minimum: 1 second
  • Maximum: 604800 seconds (7 days)

Signing Scheme

This SDK implements Stowry's native signing scheme. URLs are signed using HMAC-SHA256 with the following query parameters:

Parameter Description
X-Stowry-Credential Access key ID
X-Stowry-Date Unix timestamp (seconds)
X-Stowry-Expires Validity in seconds
X-Stowry-Signature Hex-encoded HMAC-SHA256 signature

For AWS Signature V4 compatibility, use boto3. The Stowry server supports both signing schemes.

License

MIT

About

Python SDK for generating Stowry presigned URLs

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages