Object storage

From InugamiDev/ultrathink-oss · View interactive version

Object storage is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. > S3-compatible object storage — AWS S3, Cloudflare R2, MinIO. Upload, download, presign, lifecycle.

How to use this skill

Skill file

Object Storage

S3-compatible object storage — AWS S3, Cloudflare R2, MinIO. Upload, download, presign, lifecycle.

When to Use

Core Patterns

S3/R2 Client Setup

import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";

// AWS S3
const s3 = new S3Client({ region: "us-east-1" });

// Cloudflare R2 (S3-compatible)
const r2 = new S3Client({
  region: "auto",
  endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
  credentials: { accessKeyId: R2_ACCESS_KEY, secretAccessKey: R2_SECRET_KEY },
});

Presigned URLs (Upload + Download)

// Generate upload URL (client uploads directly to S3/R2)
const uploadUrl = await getSignedUrl(s3, new PutObjectCommand({
  Bucket: "my-bucket", Key: `uploads/${crypto.randomUUID()}`,
  ContentType: "image/png",
}), { expiresIn: 600 }); // 10 min

// Generate download URL
const downloadUrl = await getSignedUrl(s3, new GetObjectCommand({
  Bucket: "my-bucket", Key: "uploads/file.png",
}), { expiresIn: 3600 });

Multipart Upload (Large Files)

import { CreateMultipartUploadCommand, UploadPartCommand, CompleteMultipartUploadCommand } from "@aws-sdk/client-s3";
import { Upload } from "@aws-sdk/lib-storage";

// High-level (recommended) — handles chunking + retries
const upload = new Upload({
  client: s3, params: { Bucket: "my-bucket", Key: "large-file.zip", Body: stream },
  partSize: 10 * 1024 * 1024, // 10MB chunks
});
upload.on("httpUploadProgress", (p) => console.log(`${p.loaded}/${p.total}`));
await upload.done();

Next.js API Route (Presigned Upload Flow)

// app/api/upload/route.ts
export async function POST(req: Request) {
  const { filename, contentType } = await req.json();
  const key = `uploads/${Date.now()}-${filename}`;
  const url = await getSignedUrl(s3, new PutObjectCommand({
    Bucket: "my-bucket", Key: key, ContentType: contentType,
  }), { expiresIn: 600 });
  return Response.json({ url, key });
}
// Client: fetch("/api/upload", { method: "POST", body: JSON.stringify({...}) })
//   .then(r => r.json()).then(({ url }) => fetch(url, { method: "PUT", body: file }));

Key Features

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.