> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 객체 저장소 청사진

> S3, Google Cloud Storage, Azure Blob 및 기타 객체 저장소 서비스에 대한 파일 업로드 및 저장 사용량을 추적합니다.

## 사용 사례

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

<CardGroup cols={2}>
  <Card title="File Hosting" icon="folder">
    총 저장 용량 사용량 및 업로드 볼륨을 기준으로 고객에게 청구합니다.
  </Card>

  <Card title="Backup Services" icon="shield">
    백업 데이터 업로드를 추적하고 저장되는 GB당 요금을 부과합니다.
  </Card>

  <Card title="Media CDN" icon="photo-film">
    미디어 업로드를 모니터링하고 저장 및 대역폭을 기준으로 청구합니다.
  </Card>

  <Card title="Document Management" icon="file">
    고객별 문서 업로드를 추적하여 사용량 기반 가격 책정을 적용합니다.
  </Card>
</CardGroup>

<Info>
  스토리지 업로드, 파일 호스팅, CDN 사용 또는 백업 서비스 요금 청구에 이상적입니다.
</Info>

## 빠른 시작

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

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    npm install @dodopayments/ingestion-blueprints
    ```
  </Step>

  <Step title="Get Your API Keys">
    * **Dodo Payments API 키**: [Dodo Payments Dashboard](https://app.dodopayments.com/developer/api-keys)에서 가져옵니다.
    * **스토리지 공급자 API 키**: AWS S3, Google Cloud Storage, Azure 등에서 가져옵니다.
  </Step>

  <Step title="Create a Meter">
    [다음 Dodo Payments Dashboard](https://app.dodopayments.com/)에서 미터를 생성하세요:

    * **이벤트 이름**: `object_storage_upload`(또는 원하는 이름)
    * **집계 유형**: `sum`으로 총 업로드 바이트를 추적합니다.
    * **Over 속성**: `bytes`으로 저장 크기를 기준으로 청구합니다.
  </Step>

  <Step title="Track Storage Usage">
    <CodeGroup>
      ```javascript AWS S3 Upload theme={null}
      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
      });
      ```

      ```javascript Google Cloud Storage theme={null}
      import { Ingestion, trackObjectStorage } from '@dodopayments/ingestion-blueprints';
      import { Storage } from '@google-cloud/storage';
      import fs from 'fs';

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

      const storage = new Storage();
      const bucket = storage.bucket('my-bucket');

      // Read the file
      const fileBuffer = fs.readFileSync('./image.png');

      // Upload to GCS
      await bucket.file('uploads/image.png').save(fileBuffer);

      // Track the upload
      await trackObjectStorage(ingestion, {
        customerId: 'customer_456',
        bytes: fileBuffer.length,
        metadata: {
          bucket: 'my-bucket',
          key: 'uploads/image.png'
        }
      });
      ```
    </CodeGroup>
  </Step>
</Steps>

## 구성

### 수집 구성

<ParamField path="apiKey" type="string" required>
  대시보드에서 가져온 Dodo Payments API 키입니다.
</ParamField>

<ParamField path="environment" type="string" required>
  환경 모드: `test_mode` 또는 `live_mode`.
</ParamField>

<ParamField path="eventName" type="string" required>
  미터 구성과 일치하는 이벤트 이름입니다.
</ParamField>

### 객체 저장소 추적 옵션

<ParamField path="customerId" type="string" required>
  청구 귀속을 위한 고객 ID입니다.
</ParamField>

<ParamField path="bytes" type="number">
  업로드된 바이트 수입니다. 바이트 기반 청구에 필요합니다.
</ParamField>

<ParamField path="metadata" type="object">
  버킷 이름, 콘텐츠 유형 등 업로드에 대한 선택적 메타데이터입니다.
</ParamField>

## 모범 사례

<Tip>
  **업로드 전후 추적**: 오류 처리 전략에 따라 실제 업로드 전후로 이벤트를 추적할 수 있습니다.
</Tip>

<Warning>
  **업로드 실패 처리**: 실패한 작업에 대해 청구하지 않도록 성공한 업로드만 추적하세요.
</Warning>
