> ## 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">
    تتبع عمليات تحميل بيانات النسخ الاحتياطي وفرض رسوم لكل جيجابايت مخزن.
  </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**: احصله من [لوحة معلومات Dodo Payments](https://app.dodopayments.com/developer/api-keys)
    * **مفتاح واجهة برمجة تطبيقات مزود التخزين**: من AWS S3، Google Cloud Storage، Azure، إلخ.
  </Step>

  <Step title="Create a Meter">
    أنشئ عدادًا في [لوحة معلومات Dodo Payments](https://app.dodopayments.com/):

    * **اسم الحدث**: `object_storage_upload` (أو الاسم الذي تفضله)
    * **نوع التجميع**: `sum` لتتبع إجمالي البايتات المحملة
    * **خاصية التجاوز**: `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 الخاص بك من لوحة المعلومات.
</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>
  معرّف العميل الخاص بنسب الفوترة.
</ParamField>

<ParamField path="bytes" type="number">
  عدد البايتات المحملة. مطلوب للفوترة المعتمدة على البايت.
</ParamField>

<ParamField path="metadata" type="object">
  بيانات وصفية اختيارية عن التحميل مثل اسم الدلو، نوع المحتوى، إلخ.
</ParamField>

## أفضل الممارسات

<Tip>
  **تتبع قبل أو بعد التحميل**: يمكنك تتبع الحدث قبل أو بعد التحميل الفعلي حسب استراتيجية معالجة الأخطاء الخاصة بك.
</Tip>

<Warning>
  **معالجة فشل التحميل**: تتبع التحميلات الناجحة فقط لتجنب الفوترة على العمليات الفاشلة.
</Warning>
