P
PUGUH

File Storage

PUGUH menyediakan file storage yang kompatibel dengan S3, dengan isolasi level organisasi, pemindaian virus otomatis, dan delivery via CDN.

Ringkasan

Layanan storage menangani:

  • Upload file dengan batas ukuran per paket
  • Isolasi organisasi — file dibatasi pada organisasi yang mengunggah
  • Pemrosesan gambar — pembuatan thumbnail dan varian secara otomatis
  • Presigned URL untuk download yang aman dan terbatas waktu
  • Kontrol visibilitas — publik atau privat per file

Mengunggah File

Via API

bash
curl -X POST https://api-puguh.arsaka.io/storage/upload \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Organization-ID: YOUR_ORG_ID" \
  -F "file=@logo.png" \
  -F "visibility=public"

Response:

json
{
  "id": "file_abc123",
  "filename": "logo.png",
  "content_type": "image/png",
  "size_bytes": 45200,
  "visibility": "public",
  "url": "https://cdn.arsaka.io/org_xxx/logo.png",
  "variants": {
    "thumbnail": "https://cdn.arsaka.io/org_xxx/logo_thumb.png",
    "medium": "https://cdn.arsaka.io/org_xxx/logo_medium.png"
  },
  "created_at": "2026-02-20T10:00:00Z"
}

Via SDK (TypeScript)

typescript
import { PuguhClient } from '@arsaka/puguh-sdk';

const client = new PuguhClient({ apiKey: 'YOUR_KEY' });

// Upload a file
const file = await client.storage.upload(fileBlob, {
  visibility: 'public',
  organizationId: 'org_abc'
});

console.log(file.url);       // Public CDN URL
console.log(file.variants);  // { thumbnail, medium }

Via SDK (Python)

python
from puguh_sdk import PuguhClient

client = PuguhClient(api_key="YOUR_KEY")

with open("logo.png", "rb") as f:
    file = client.storage.upload(f, visibility="public")

print(file.url)
print(file.variants)

Visibilitas File

VisibilitasAksesTipe URL
publicSiapa saja dengan URLURL CDN permanen
privateHanya pengguna terotentikasiPresigned URL (kadaluarsa)

Mengubah Visibilitas

bash
curl -X PATCH https://api-puguh.arsaka.io/storage/file_abc123/visibility \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"visibility": "private"}'

Presigned URL

Buat URL download terbatas waktu untuk file privat:

bash
curl -X POST https://api-puguh.arsaka.io/storage/file_abc123/presign \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"expires_in": 3600}'

Response:

json
{
  "url": "https://cdn.arsaka.io/org_xxx/file_abc123?token=xxx&expires=1708430400",
  "expires_at": "2026-02-20T11:00:00Z"
}

Varian Gambar

Saat Anda mengunggah gambar (PNG, JPG, WebP), PUGUH secara otomatis membuat varian:

VarianUkuran MaksFormat
thumbnail150x150WebP
medium600x600WebP
originalSesuai unggahanOriginal

Melihat Daftar File

bash
curl https://api-puguh.arsaka.io/storage?page=1&page_size=20 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Organization-ID: YOUR_ORG_ID"

Response:

json
{
  "items": [
    {
      "id": "file_abc123",
      "filename": "logo.png",
      "content_type": "image/png",
      "size_bytes": 45200,
      "visibility": "public",
      "created_at": "2026-02-20T10:00:00Z"
    }
  ],
  "total": 42,
  "page": 1,
  "page_size": 20,
  "has_next": true,
  "has_prev": false
}

Menghapus File

bash
curl -X DELETE https://api-puguh.arsaka.io/storage/file_abc123 \
  -H "Authorization: Bearer YOUR_TOKEN"

File yang dihapus menggunakan soft-delete dan dapat dipulihkan dalam 30 hari.

Penggunaan Storage

bash
curl https://api-puguh.arsaka.io/storage/usage \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Organization-ID: YOUR_ORG_ID"

Response:

json
{
  "used_bytes": 524288000,
  "quota_bytes": 5368709120,
  "file_count": 156,
  "usage_percent": 9.8
}

Batas per Paket

PaketStorageUkuran File MaksBandwidth
Free1 GB10 MB5 GB/bulan
Pro10 GB100 MB50 GB/bulan
Business100 GB500 MB500 GB/bulan
EnterpriseCustomCustomCustom

Tipe File yang Diizinkan

Secara default, PUGUH mengizinkan tipe file umum. Admin organisasi dapat menyesuaikan tipe yang diizinkan melalui kebijakan.

KategoriEkstensi
Gambar.png, .jpg, .jpeg, .gif, .webp, .svg
Dokumen.pdf, .doc, .docx, .xls, .xlsx, .csv
Arsip.zip, .tar.gz
Lainnya.json, .xml, .txt

Praktik Terbaik

  1. Gunakan presigned URL untuk file privat alih-alih mem-proxy melalui server Anda
  2. Atur visibilitas yang tepat saat upload (publik untuk logo/aset, privat untuk dokumen pengguna)
  3. Gunakan varian gambar alih-alih menyajikan gambar ukuran penuh untuk thumbnail
  4. Pantau penggunaan storage untuk menghindari batas paket
  5. Bersihkan file yang tidak terpakai secara berkala

Terkait