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

# رفع ملف

> POST /media/

يرفع ملفًا، على مضيف **واجهة برمجة التطبيقات للإدارة** (`api.scanova.io`)، مع المصادقة باستخدام مفتاح واجهة برمجة التطبيقات للإدارة الخام الخاص بك.

```
POST https://api.scanova.io/media/
Authorization: 401f7ac837da42b97f613d789819ff93537bee6a
Content-Type: multipart/form-data
```

<ParamField body="file" type="file" required>
  الملف المراد رفعه. يلزم توفير `file` أو `upload`.
</ParamField>

<ParamField body="upload" type="file">
  اسم بديل لـ `file` — قدّم أحدهما.
</ParamField>

<ParamField body="file_type" type="string">
  فئات مفصولة بفواصل يُقيَّد بها التحقق (`image` و`video` و`audio` و`pdf` و`doc` و`script`). راجع [سرد أنواع الملفات المسموح بها](/ar/api-reference/management-api/user-media/allowed-files) لمعرفة معايير القبول لكل فئة.
</ParamField>

<ParamField body="in_use" type="string">
  كيفية استخدام هذا الملف: `avatar` أو `qr_logo` أو `qr_content` أو `poster` أو `qr_image` أو `profile_pic` أو `banner` أو `smart` أو `thumbnail`، أو `unknown` (الافتراضي).
</ParamField>

<ParamField body="category" type="string">
  تسمية فئة بنص حر، مثل رمز فئة رمز QR أو `"Custom Design"`.
</ParamField>

<ParamField body="bulk_media" type="integer">
  معرّف دفعة وسائط مجمّعة، من [إنشاء دفعة وسائط مجمّعة](/ar/api-reference/management-api/user-media/bulk-create)، لربط هذا الرفع بها.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.scanova.io/media/" \
    -H "Authorization: 401f7ac837da42b97f613d789819ff93537bee6a" \
    -F "file=@logo.png" \
    -F "in_use=qr_logo" \
    -F "category=custom-design"
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": 4821,
    "file": "media/uploads/104/2026/09/20260908_512873_logo.png",
    "upload": null,
    "file_name": "20260908_512873_logo.png",
    "size": 48213,
    "human_readable_size": "47.08 KB",
    "original_name": "logo.png",
    "bulk_media": null,
    "mime_type": "image/png",
    "file_type": "png",
    "in_use": "qr_logo",
    "category": "custom-design",
    "created": "2026-09-08T10:15:32.120Z",
    "modified": "2026-09-08T10:15:32.120Z"
  }
  ```
</ResponseExample>

## التحقق

* يجب أن يكون **الامتداد ونوع MIME** كلاهما ضمن القائمة المسموح بها للفئة `file_type` المكتشفة — يُرفض أي تعارض (مثل امتداد `.png` لملف هو في الواقع PDF).
* يُتحقق من **الحجم** مقابل حد الفئة — باستثناء ملفات `pdf`/`doc`، حيث تحل حصة الخطة `DOCUMENT_FILE_SIZE` الخاصة بالحساب (بالميغابايت) محل الحد الثابت.
* يُحلَّل **JavaScript** (`.js`) المرفوع للتأكد من أنه صياغة JS صحيحة قبل التحقق من الحجم.
* تُفحص ملفات **SVG** بحثًا عن نصوص برمجية مضمّنة وتُرفض في حال العثور عليها.
* تُرفض الملفات بدون امتداد تمامًا.

يُعاد `400` عند أي من أخطاء التحقق أعلاه، مع رسالة تحدد المشكلة.

## ذو صلة

* [سرد الملفات المرفوعة](/ar/api-reference/management-api/user-media/list) — رؤية ما تم رفعه بالفعل.
* [سرد أنواع الملفات المسموح بها](/ar/api-reference/management-api/user-media/allowed-files) — التحقق من جانب العميل قبل الرفع.
* [حذف ملف](/ar/api-reference/management-api/user-media/delete) — إزالة ملف.
* [نظرة عامة على واجهة برمجة التطبيقات للإدارة](/ar/api-reference/management-api/overview) — مخطط المصادقة وقواعد الحصة المطبّقة على هذا الطرف.


## OpenAPI

````yaml api-reference/openapi/management-api.json POST /media/
openapi: 3.1.0
info:
  title: Scanova Management API (v2)
  description: >-
    The complete Scanova Management API — every endpoint available at
    api.scanova.io (QR codes, folders, tags, leads, forms, analytics, plans,
    shared users & roles), plus the token-creation and usage-stats endpoints
    used to authenticate against it. Every path and request/response shape below
    was verified live against a real API key and the actual running backend
    (Phase 7, 2026-08-16) — not guessed from reading urls.py alone.
  version: 2.0.0
servers:
  - url: https://api.scanova.io
    description: Management API — QR/folder/tag/lead/form/analytics/plans endpoints
security:
  - apiKeyAuth: []
paths:
  /media/:
    post:
      summary: Upload a file
      description: >-
        Multipart file upload. Validates extension, MIME type, and size against
        the file_type's allow-list (or the account's DOCUMENT_FILE_SIZE quota
        for pdf/doc files); JavaScript uploads are additionally parsed to
        confirm they're syntactically valid, and SVGs are scanned for embedded
        scripts.
      operationId: uploadMedia
      requestBody:
        content:
          multipart/form-data:
            example:
              file: (binary file)
              in_use: qr_logo
              category: custom-design
      responses:
        '201':
          description: File uploaded.
          content:
            application/json:
              example:
                id: 4821
                file: media/uploads/104/2026/09/20260908_512873_logo.png
                upload: null
                file_name: 20260908_512873_logo.png
                size: 48213
                human_readable_size: 47.08 KB
                original_name: logo.png
                bulk_media: null
                mime_type: image/png
                file_type: png
                in_use: qr_logo
                category: custom-design
                created: '2026-09-08T10:15:32.120Z'
                modified: '2026-09-08T10:15:32.120Z'
        '400':
          description: >-
            Missing file, no extension, MIME/extension mismatch, invalid
            JavaScript, SVG failed the XSS scan, or file size exceeds the
            allowed limit.
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Send your Management API key as the raw value of the Authorization
        header — no "Bearer " or "Token " prefix, and no other characters.
        Example: `Authorization: 401f7ac837da42b97f613d789819ff93537bee6a`. A
        header containing more than one space-separated part is rejected
        outright. Requests also require the request's Host header to be the
        management API host (e.g. api.scanova.io) — the same key sent to the
        regular API host will not authenticate.

````