> ## 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.

# Blueprint Penyimpanan Objek

> Lacak unggahan file dan penggunaan penyimpanan untuk S3, Google Cloud Storage, Azure Blob, dan layanan penyimpanan objek lainnya.

## Kasus Penggunaan

Jelajahi skenario umum yang didukung oleh Blueprint Penyimpanan Objek:

<CardGroup cols={2}>
  <Card title="File Hosting" icon="folder">
    Tagih pelanggan berdasarkan total penggunaan penyimpanan dan volume unggahan.
  </Card>

  <Card title="Backup Services" icon="shield">
    Lacak unggahan data cadangan dan kenakan biaya per GB yang disimpan.
  </Card>

  <Card title="Media CDN" icon="photo-film">
    Pantau unggahan media dan tagih untuk penyimpanan serta bandwidth.
  </Card>

  <Card title="Document Management" icon="file">
    Lacak unggahan dokumen per pelanggan untuk harga berbasis penggunaan.
  </Card>
</CardGroup>

<Info>
  Sangat cocok untuk penagihan berdasarkan unggahan penyimpanan, hosting file, penggunaan CDN, atau layanan cadangan.
</Info>

## Memulai dengan Cepat

Lacak unggahan penyimpanan objek dengan byte yang digunakan:

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

  <Step title="Get Your API Keys">
    * **Kunci API Dodo Payments**: Dapatkan dari [Dodo Payments Dashboard](https://app.dodopayments.com/developer/api-keys)
    * **Kunci API Penyedia Penyimpanan**: Dari AWS S3, Google Cloud Storage, Azure, dll.
  </Step>

  <Step title="Create a Meter">
    Buat meter di [Dodo Payments Dashboard](https://app.dodopayments.com/):

    * **Nama Acara**: `object_storage_upload` (atau nama pilihan Anda)
    * **Jenis Agregasi**: `sum` untuk melacak total byte yang diunggah
    * **Properti Over**: `bytes` untuk menagih berdasarkan ukuran penyimpanan
  </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>

## Konfigurasi

### Konfigurasi Ingesti

<ParamField path="apiKey" type="string" required>
  Kunci API Dodo Payments Anda dari dasbor.
</ParamField>

<ParamField path="environment" type="string" required>
  Mode lingkungan: `test_mode` atau `live_mode`.
</ParamField>

<ParamField path="eventName" type="string" required>
  Nama acara yang sesuai dengan konfigurasi meter Anda.
</ParamField>

### Opsi Lacak Penyimpanan Objek

<ParamField path="customerId" type="string" required>
  ID pelanggan untuk atribusi penagihan.
</ParamField>

<ParamField path="bytes" type="number">
  Jumlah byte yang diunggah. Diperlukan untuk penagihan berbasis byte.
</ParamField>

<ParamField path="metadata" type="object">
  Metadata opsional tentang unggahan seperti nama bucket, tipe konten, dll.
</ParamField>

## Praktik Terbaik

<Tip>
  **Lacak Sebelum atau Sesudah Unggah**: Anda dapat melacak acara sebelum atau sesudah unggahan aktual tergantung strategi penanganan kesalahan Anda.
</Tip>

<Warning>
  **Tangani Kegagalan Unggahan**: Hanya lacak unggahan yang berhasil untuk menghindari penagihan untuk operasi yang gagal.
</Warning>
