메인 콘텐츠로 건너뛰기

사용 사례

객체 저장소 청사진에서 지원하는 일반적인 시나리오를 탐색합니다:

File Hosting

총 저장 용량 사용량 및 업로드 볼륨을 기준으로 고객에게 청구합니다.

Backup Services

백업 데이터 업로드를 추적하고 저장되는 GB당 요금을 부과합니다.

Media CDN

미디어 업로드를 모니터링하고 저장 및 대역폭을 기준으로 청구합니다.

Document Management

고객별 문서 업로드를 추적하여 사용량 기반 가격 책정을 적용합니다.
스토리지 업로드, 파일 호스팅, CDN 사용 또는 백업 서비스 요금 청구에 이상적입니다.

빠른 시작

소비된 바이트로 객체 저장소 업로드를 추적합니다:
1

Install the SDK

npm install @dodopayments/ingestion-blueprints
2

Get Your API Keys

  • Dodo Payments API 키: Dodo Payments Dashboard에서 가져옵니다.
  • 스토리지 공급자 API 키: AWS S3, Google Cloud Storage, Azure 등에서 가져옵니다.
3

Create a Meter

다음 Dodo Payments Dashboard에서 미터를 생성하세요:
  • 이벤트 이름: object_storage_upload(또는 원하는 이름)
  • 집계 유형: sum으로 총 업로드 바이트를 추적합니다.
  • Over 속성: bytes으로 저장 크기를 기준으로 청구합니다.
4

Track Storage Usage

import { Ingestion, trackObjectStorage } from '@dodopayments/ingestion-blueprints';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import fs from 'fs';

const ingestion = new Ingestion({
  apiKey: process.env.DODO_PAYMENTS_API_KEY,
  environment: 'test_mode',
  eventName: 'object_storage_upload'
});

const s3 = new S3Client({ region: 'us-east-1' });

// Read the file (example: from disk or request)
const fileBuffer = fs.readFileSync('./document.pdf');

// Upload to S3
const command = new PutObjectCommand({
  Bucket: 'my-bucket',
  Key: 'uploads/document.pdf',
  Body: fileBuffer
});

await s3.send(command);

// Track the upload
await trackObjectStorage(ingestion, {
  customerId: 'customer_123',
  bytes: fileBuffer.length
});

구성

수집 구성

apiKey
string
필수
대시보드에서 가져온 Dodo Payments API 키입니다.
environment
string
필수
환경 모드: test_mode 또는 live_mode.
eventName
string
필수
미터 구성과 일치하는 이벤트 이름입니다.

객체 저장소 추적 옵션

customerId
string
필수
청구 귀속을 위한 고객 ID입니다.
bytes
number
업로드된 바이트 수입니다. 바이트 기반 청구에 필요합니다.
metadata
object
버킷 이름, 콘텐츠 유형 등 업로드에 대한 선택적 메타데이터입니다.

모범 사례

업로드 전후 추적: 오류 처리 전략에 따라 실제 업로드 전후로 이벤트를 추적할 수 있습니다.
업로드 실패 처리: 실패한 작업에 대해 청구하지 않도록 성공한 업로드만 추적하세요.