본문으로 건너뛰기

파일 스토리지 API

파일 업로드/조회 엔드포인트입니다. 업로드는 Presigned URL 방식으로 진행됩니다:

  1. presigned-url 발급
  2. 발급받은 URL 로 Object Storage 에 직접 PUT
  3. complete-upload 호출

Presigned URL 생성

POST /v1/public/storages/files/:storageID/presigned-url

bash
curl -X POST "https://api.connectbase.world/v1/public/storages/files/stg_xxx/presigned-url" \
  -H "X-Public-Key: cb_pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "avatar.png",
    "file_size": 102400,
    "mime_type": "image/png",
    "parent_id": "folder_xxx"
  }'

응답:

json
{
  "file_id": "file_abc",
  "upload_url": "https://objectstorage.example.com/...?signature=...",
  "public_url": "https://cdn.connectbase.world/..."
}

Object Storage 에 직접 업로드

bash
curl -X PUT "<upload_url>" \
  -H "Content-Type: image/png" \
  --data-binary "@avatar.png"

업로드 완료 알림

POST /v1/public/storages/files/:storageID/complete-upload

bash
curl -X POST "https://api.connectbase.world/v1/public/storages/files/stg_xxx/complete-upload" \
  -H "X-Public-Key: cb_pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{ "file_id": "file_abc" }'

응답:

json
{
  "id": "file_abc",
  "name": "avatar.png",
  "path": "/avatar.png",
  "type": "file",
  "mime_type": "image/png",
  "size": 102400,
  "url": "https://cdn.connectbase.world/...",
  "parent_id": "folder_xxx",
  "created_at": "2026-04-09T00:00:00Z"
}

파일 목록 조회

GET /v1/public/storages/files/:storageID/items

bash
curl -X GET "https://api.connectbase.world/v1/public/storages/files/stg_xxx/items" \
  -H "X-Public-Key: cb_pk_your_public_key"

응답:

json
{
  "files": [
    {
      "id": "file_abc",
      "name": "avatar.png",
      "path": "/avatar.png",
      "type": "file",
      "mime_type": "image/png",
      "size": 102400,
      "url": "https://cdn.connectbase.world/...",
      "created_at": "2026-04-09T00:00:00Z",
      "updated_at": "2026-04-09T00:00:00Z"
    }
  ]
}

폴더 생성

POST /v1/public/storages/files/:storageID/folders

bash
curl -X POST "https://api.connectbase.world/v1/public/storages/files/stg_xxx/folders" \
  -H "X-Public-Key: cb_pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{ "name": "avatars" }'

파일 삭제

DELETE /v1/public/storages/files/:storageID/items/:fileID

bash
curl -X DELETE "https://api.connectbase.world/v1/public/storages/files/stg_xxx/items/file_abc" \
  -H "X-Public-Key: cb_pk_your_public_key"

경로 기반 업로드 (덮어쓰기)

POST /v1/public/storages/files/:storageID/presigned-url/path/*path

같은 경로에 다시 업로드하면 파일만 교체되어 URL이 유지됩니다.

bash
curl -X POST "https://api.connectbase.world/v1/public/storages/files/stg_xxx/presigned-url/path/profiles/user123/avatar.png" \
  -H "X-Public-Key: cb_pk_your_public_key" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "avatar.png",
    "file_size": 102400,
    "mime_type": "image/png",
    "overwrite": true
  }'

이후 PUT + complete-upload 단계는 일반 업로드와 동일합니다.

경로로 파일 조회

GET /v1/public/storages/files/:storageID/path/*path

bash
curl -X GET "https://api.connectbase.world/v1/public/storages/files/stg_xxx/path/profiles/user123/avatar.png" \
  -H "X-Public-Key: cb_pk_your_public_key"