Skip to main content

Overview

Integrate Raily with Amazon S3 to store and serve your content while maintaining full access control and analytics. Raily manages authentication, authorization, and tracking while your content remains in your S3 buckets.

Setup

Prerequisites

  • AWS Account with S3 access
  • AWS Access Key ID and Secret Access Key
  • S3 bucket for your content

Configuration

import Raily from '@raily/sdk';

const raily = new Raily({
  apiKey: process.env.RAILY_API_KEY
});

// Configure S3 storage
await raily.storage.connect({
  provider: 's3',
  config: {
    region: 'us-east-1',
    bucket: 'your-content-bucket',
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
  }
});

Uploading Content

// Upload content to S3 via Raily
const content = await raily.content.create({
  title: "AI Research Report 2024",
  type: "document",
  storage: {
    provider: "s3",
    key: "reports/ai-research-2024.pdf"
  },
  file: fileBuffer,
  metadata: {
    category: "research",
    year: 2024
  }
});

Accessing Content

// Access S3 content through Raily
const access = await raily.access.check({
  contentId: "cnt_report_2024",
  requesterId: "app_id",
  context: {
    purpose: "inference"
  }
});

if (access.allowed) {
  // Raily provides a signed URL to access the S3 object
  const response = await fetch(access.contentUrl);
  const content = await response.blob();
}

Best Practices

Bucket Policies

Configure S3 bucket policies to allow Raily to read and write objects securely.

Lifecycle Rules

Use S3 lifecycle policies to archive or delete old content automatically.

Versioning

Enable S3 versioning to maintain content history and rollback capability.

Encryption

Use S3 server-side encryption (SSE) for data at rest security.

Next Steps