Skip to content

Getting Started

This guide will have you running Stowry and storing your first file in 5 minutes.

  • A terminal/command line
  • curl for making HTTP requests (or any HTTP client)

Download the latest release for your platform:

Terminal window
# Linux (amd64)
curl -LO https://github.com/sagarc03/stowry/releases/latest/download/stowry-linux-amd64
chmod +x stowry-linux-amd64
mv stowry-linux-amd64 stowry
# macOS (arm64)
curl -LO https://github.com/sagarc03/stowry/releases/latest/download/stowry-darwin-arm64
chmod +x stowry-darwin-arm64
mv stowry-darwin-arm64 stowry

Create a config.yaml file:

server:
port: 5708
mode: store
database:
type: sqlite
dsn: stowry.db
table: stowry_metadata
auto_migrate: true
storage:
path: ./data
auth:
region: us-east-1
service: s3
keys:
- access_key: AKIAIOSFODNN7EXAMPLE
secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
access:
public_read: false
public_write: false
log:
level: info

The config above uses auto_migrate: true, which automatically creates the database tables on startup. This is the easiest option for getting started.

The table name (stowry_metadata in this example) can be anything you want - just make sure it matches between your config and the SQL schema.

Alternative: Manual Migration

If you prefer to manage the schema yourself, remove auto_migrate: true and run the SQL manually (replace stowry_metadata with your chosen table name):

CREATE TABLE IF NOT EXISTS stowry_metadata (
id TEXT NOT NULL PRIMARY KEY,
path TEXT NOT NULL UNIQUE,
content_type TEXT NOT NULL,
etag TEXT NOT NULL,
file_size_bytes INTEGER NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
deleted_at TEXT,
cleaned_up_at TEXT
);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_deleted_at
ON stowry_metadata (deleted_at);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_pending_cleanup
ON stowry_metadata (deleted_at, cleaned_up_at);
CREATE INDEX IF NOT EXISTS idx_stowry_metadata_active_list
ON stowry_metadata (created_at, path);
Terminal window
./stowry serve

You should see:

INFO starting server addr=:5708 mode=store

Stowry uses presigned URLs for authentication. For this quick test, enable public write access temporarily by setting public_write: true in your config, then restart the server.

Upload a file:

Terminal window
curl -X PUT \
-H "Content-Type: text/plain" \
-d "Hello, Stowry!" \
http://localhost:5708/hello.txt

Response:

{
"id": "550e8400-e29b-41d4-a716-446655440000",
"path": "hello.txt",
"content_type": "text/plain",
"etag": "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e",
"file_size_bytes": 14,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Terminal window
curl http://localhost:5708/hello.txt

Output:

Hello, Stowry!

For production, disable public access and use presigned URLs. See the Authentication guide for generating presigned URLs with the stowry-go SDK or AWS SDK.

import stowry "github.com/sagarc03/stowry-go"
client := stowry.NewClient(
"http://localhost:5708",
"AKIAIOSFODNN7EXAMPLE",
"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
)
// Generate a presigned URL valid for 15 minutes
uploadURL := client.PresignPut("/photos/vacation.jpg", 900)