Platform
Storage
Overview

Storage

Base URL: https://storage-api.pcampus.co

Overview

Storage คือ object storage service สำหรับเก็บและให้บริการ files ทุกประเภทที่ใช้ใน Pcampus ecosystem ตั้งแต่ brand assets ของ Content OS, creative files ของ Cockpit, ไปจนถึงไฟล์ที่ developer ลูกค้าอัพโหลดผ่าน app ของตัวเอง รองรับ CDN delivery เพื่อให้ผู้ใช้ได้รับไฟล์เร็ว

Who uses this

Personaใช้ทำอะไร
Internal serviceContent OS, Cockpit เรียก API เก็บ assets และดึง URL
Developer (ลูกค้า)อัพโหลดและให้บริการไฟล์ของ app ตัวเอง (user avatars, documents, etc.)
End userอัพโหลด profile picture, document ผ่าน app
Adminดู storage usage, จัดการ buckets

Key features

  • File upload — รองรับ direct upload และ presigned URL upload (สำหรับ client-side)
  • Bucket management — แยก bucket ตาม organization และ use case (public, private)
  • CDN delivery — ทุก public file serve ผ่าน CDN endpoint ทั่วโลก
  • Image transformation — resize, crop, compress on-the-fly ผ่าน URL parameters
  • Access control — Public bucket (ไม่ต้อง auth) vs. Private bucket (ต้องมี signed URL)
  • Usage tracking — ติดตาม storage used และ bandwidth consumed ต่อ org
  • File metadata — เก็บ MIME type, file size, tags, และ custom metadata

User stories

Content OS (internal):

"เมื่อ brand manager อัพโหลด logo ต้องการเก็บใน storage แล้วได้ CDN URL กลับมาใช้แสดงผล"

→ Content OS เรียก POST /storage/upload → ได้ file_url → เก็บใน Content OS DB → แสดงผลผ่าน CDN URL

Developer (ลูกค้า):

"ผมต้องการให้ user อัพโหลด profile picture โดยไม่ต้องส่งไฟล์ผ่าน backend ผม"

POST /storage/presigned-url → ได้ presigned URL → client อัพโหลดตรงถึง Storage → ได้ public URL

Admin:

"ผมต้องการดู storage usage ของ org เพื่อตรวจสอบว่าใกล้ถึง limit แล้วหรือยัง"

→ Console → Storage → Usage dashboard → เห็น used / limit per bucket

How it works

Direct upload flow:

Presigned URL flow (client-side upload):

Data model

Integration

  • Content OS — เก็บ brand logos, images, content attachments
  • Cockpit — เก็บ campaign creative files
  • PIP — ทุก upload ผ่าน access check (storage.upload, storage.read)
  • Billing — ส่ง usage metrics (bytes used, bandwidth) ให้ Billing คำนวณ

Image transformation

Public images รองรับ transformation ผ่าน URL query params:

# Resize to 400x300
https://cdn.pcampus.co/files/abc123.jpg?w=400&h=300

# Crop (center) and compress
https://cdn.pcampus.co/files/abc123.jpg?w=400&h=300&fit=cover&q=80

# Convert format
https://cdn.pcampus.co/files/abc123.jpg?format=webp

API overview

MethodEndpointDescription
POST/storage/uploadUpload file directly
POST/storage/presigned-urlGet presigned URL for client upload
GET/storage/filesList files in org
GET/storage/files/:idGet file metadata
DELETE/storage/files/:idDelete file
PATCH/storage/files/:idUpdate file metadata / tags
GET/storage/bucketsList buckets
POST/storage/bucketsCreate bucket
GET/storage/usageGet storage usage for org

Upload response

{
  "fileId": "file_xxxx",
  "filename": "logo.png",
  "mimeType": "image/png",
  "sizeBytes": 204800,
  "url": "https://storage-api.pcampus.co/files/file_xxxx",
  "cdnUrl": "https://cdn.pcampus.co/files/file_xxxx/logo.png"
}
⚠️

Private bucket files ต้องใช้ signed URL ที่มีอายุจำกัด — อย่า expose storage_path โดยตรง

Storage

Base URL: https://storage-api.pcampus.co

Overview

Storage is the object storage service for storing and serving all file types used in the Pcampus ecosystem — from brand assets in Content OS and creative files in Cockpit, to files that customer developers upload through their own apps. It supports CDN delivery so end users receive files quickly.

Who uses this

PersonaWhat they do
Internal serviceContent OS, Cockpit call the API to store assets and retrieve URLs
Developer (customer)Upload and serve files for their own app (user avatars, documents, etc.)
End userUpload a profile picture or document via an app
AdminView storage usage, manage buckets

Key features

  • File upload — Supports direct upload and presigned URL upload (for client-side uploads)
  • Bucket management — Buckets are separated by organization and use case (public, private)
  • CDN delivery — All public files are served through a global CDN endpoint
  • Image transformation — Resize, crop, and compress on-the-fly via URL parameters
  • Access control — Public bucket (no auth required) vs. Private bucket (requires a signed URL)
  • Usage tracking — Track storage used and bandwidth consumed per org
  • File metadata — Store MIME type, file size, tags, and custom metadata

User stories

Content OS (internal):

"When a brand manager uploads a logo, I need it stored and a CDN URL returned for display."

→ Content OS calls POST /storage/upload → receives file_url → stores it in the Content OS DB → renders via CDN URL

Developer (customer):

"I want users to upload profile pictures without the file passing through my backend."

POST /storage/presigned-url → receive a presigned URL → client uploads directly to Storage → receive a public URL

Admin:

"I want to see an org's storage usage to check whether it's approaching the limit."

→ Console → Storage → Usage dashboard → see used / limit per bucket

How it works

Direct upload flow:

Presigned URL flow (client-side upload):

Data model

Integration

  • Content OS — Stores brand logos, images, and content attachments
  • Cockpit — Stores campaign creative files
  • PIP — Every upload goes through an access check (storage.upload, storage.read)
  • Billing — Sends usage metrics (bytes used, bandwidth) to Billing for calculation

Image transformation

Public images support on-the-fly transformation via URL query params:

# Resize to 400x300
https://cdn.pcampus.co/files/abc123.jpg?w=400&h=300

# Crop (center) and compress
https://cdn.pcampus.co/files/abc123.jpg?w=400&h=300&fit=cover&q=80

# Convert format
https://cdn.pcampus.co/files/abc123.jpg?format=webp

API overview

MethodEndpointDescription
POST/storage/uploadUpload file directly
POST/storage/presigned-urlGet presigned URL for client upload
GET/storage/filesList files in org
GET/storage/files/:idGet file metadata
DELETE/storage/files/:idDelete file
PATCH/storage/files/:idUpdate file metadata / tags
GET/storage/bucketsList buckets
POST/storage/bucketsCreate bucket
GET/storage/usageGet storage usage for org

Upload response

{
  "fileId": "file_xxxx",
  "filename": "logo.png",
  "mimeType": "image/png",
  "sizeBytes": 204800,
  "url": "https://storage-api.pcampus.co/files/file_xxxx",
  "cdnUrl": "https://cdn.pcampus.co/files/file_xxxx/logo.png"
}
⚠️

Private bucket files require a time-limited signed URL — never expose storage_path directly.