ObitoX Docs
Providers
Storage ProviderENTERPRISE STANDARD

S3

Industry standard object storage.

Works with AWS S3 and any S3-compatible storage (MinIO, DigitalOcean Spaces, Wasabi, etc).

How it works

Unified API for all S3 providers. Switch providers just by changing credentials.

Your App
Client
Standard API
One Format
ObitoX
Universal SDK
Routes To
AWS S3
Any S3 Compatible
Flexible Config
Secure Defaults
Multi-Cloud

⚙️Setup

Initialize the ObitoX client with your S3 credentials

typescript
1import ObitoX from '@obitox/upload';
2
3const client = new ObitoX({
4 apiKey: process.env.OBITOX_API_KEY,
5 apiSecret: process.env.OBITOX_API_SECRET
6});
7
8const s3 = client.s3({
9 accessKey: process.env.S3_ACCESS_KEY,
10 secretKey: process.env.S3_SECRET_KEY,
11 bucket: 'my-bucket',
12 region: 'us-east-1'
13});

Setup Options

🔌Custom Endpoint (S3 Compatible)

Works with MinIO, DigitalOcean Spaces, or any generic S3 API.

typescript
1const s3 = client.s3({
2 accessKey: 'minioadmin',
3 secretKey: 'minioadmin123',
4 bucket: 'local-bucket',
5 endpoint: 'http://localhost:9000',
6 region: 'us-east-1'
7});

Direct API

Alternative setup: pass credentials per-call (Direct API)

typescript
1const fileUrl = await client.uploadFile(file, {
2 provider: 'S3',
3 s3AccessKey: 'key',
4 s3SecretKey: 'secret',
5 s3Bucket: 'bucket',
6 s3Region: 'us-east-1'
7});

Upload Features

📤Basic Upload

typescript
1const url = await s3.upload(file, {
2 filename: 'document.txt'
3});

Note: Smart Expiry/Network-Aware uploads are enabled by default for browser uploads. See Smart Expiry below.

📊Progress Tracking

Monitor upload progress

typescript
1const url = await s3.upload(file, {
2 filename: 'video.mp4',
3 onProgress: (percent, uploaded, total) => {
4 console.log(`${percent}% — ${uploaded}/${total} bytes`);
5 }
6});

Signed URL Expiry

Set custom expiry for returned URLs

typescript
1const url = await s3.upload(file, {
2 filename: 'doc.txt',
3 expiresIn: 3600
4});

📡Smart Expiry (Network-Aware)

SDK automatically detects network conditions in the browser to set optimal URL expiry.

Automatic: In the browser, the SDK automatically uses navigator.connection to optimize timeouts.
typescript
1// 1. Auto-Detect (Default in Browser)
2// SDK automatically uses navigator.connection
3const url = await s3.upload(file, {
4 filename: 'video.mp4'
5});
6
7// 2. Manual Override (Server-side or custom)
8const url = await s3.upload(file, {
9 filename: 'video.mp4',
10 networkInfo: {
11 type: '4g',
12 downlink: 10, // Mbps
13 rtt: 50 // ms
14 }
15});

🕵️Magic Bytes Validation

Validate file content matches extension

Client-Side Feature: This is an ObitoX SDK feature that validates files before upload using magic byte inspection.
typescript
1const url = await s3.upload(file, {
2 filename: 'photo.jpg',
3 validation: 'images'
4});

Validation presets: 'images' | 'documents'

Multipart Upload

📦Automatic Multipart

Large files (>100MB by default) are automatically split and uploaded in parts.

typescript
1// Automatic for large files
2const url = await s3.upload(largeFile, {
3 filename: 'archive.zip',
4 onProgress: (p) => console.log(p)
5});

Batch Upload

📚Batch Upload

Generate presigned URLs for multiple files in one API call.

typescript
1const result = await s3.batchUpload({
2 files: [
3 { filename: 'a.txt', contentType: 'text/plain', fileSize: 100 },
4 { filename: 'b.jpg', contentType: 'image/jpeg', fileSize: 500 }
5 ]
6});
7console.log(result.summary);

Download URL

🔗Signed Download URLs

typescript
1const url = await s3.getSignedDownloadUrl({
2 fileKey: 'doc.txt',
3 expiresIn: 3600
4});

Management

📋List Files

typescript
1const res = await s3.list({ maxKeys: 100 });
2res.files.forEach(f => console.log(f.key));

🗑️Delete Files

typescript
1await s3.delete({ fileKey: 'doc.txt' });

Auto CORS Configuration

🌐Configure CORS

Set CORS rules on your S3 bucket

typescript
1await s3.configureCors({
2 origins: ['https://example.com'],
3 allowedMethods: ['GET', 'POST']
4});

File Metadata

📄Get File Metadata

Get file metadata without downloading

typescript
1const meta = await s3.getMetadata({ key: 'doc.txt' });

Webhooks

Notification system for upload completion.

Auto Trigger

Server confirms automatically

typescript
1const url = await s3.upload(file, {
2 filename: 'report.pdf',
3 webhook: {
4 url: 'https://api.myapp.com/hooks',
5 trigger: 'auto'
6 }
7});

👆Manual Trigger

You confirm when ready

typescript
1const url = await s3.upload(file, {
2 filename: 'invoice.pdf',
3 webhook: {
4 url: 'https://api.myapp.com/hooks',
5 trigger: 'manual',
6 secret: 'secret-key'
7 }
8});

🔐Signature Verification

Verify webhook authenticity on your server

typescript
1import crypto from 'crypto';
2
3function verify(payload, signature, secret) {
4 const hmac = crypto.createHmac('sha256', secret);
5 hmac.update(JSON.stringify(payload));
6 return signature === `sha256=${hmac.digest('hex')}`;
7}

That's it!

Any S3 provider, one unified SDK.

Upload securely, handle large files automatically, and switch providers instantly.
ObitoX handles the complexity for you.

On this page