Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 37 for upload_file (0.18 sec)

  1. docs/zh/docs/tutorial/request-files.md

    文件作为「表单数据」上传。
    
    如果把*路径操作函数*参数的类型声明为 `bytes`,**FastAPI** 将以 `bytes` 形式读取和接收文件内容。
    
    这种方式把文件的所有内容都存储在内存里,适用于小型文件。
    
    不过,很多情况下,`UploadFile` 更好用。
    
    ## 含 `UploadFile` 的文件参数
    
    定义文件参数时使用 `UploadFile`:
    
    ```Python hl_lines="12"
    {!../../../docs_src/request_files/tutorial001.py!}
    ```
    
    `UploadFile` 与 `bytes` 相比有更多优势:
    
    * 使用 `spooled` 文件:
        * 存储在内存的文件超出最大上限时,FastAPI 会把文件存入磁盘;
    * 这种方式更适于处理图像、视频、二进制文件等大型文件,好处是不会占用所有内存;
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 6.9K bytes
    - Viewed (0)
  2. docs/ru/docs/tutorial/request-files.md

    Следует иметь в виду, что все содержимое будет храниться в памяти. Это хорошо подходит для небольших файлов.
    
    Однако возможны случаи, когда использование `UploadFile` может оказаться полезным.
    
    ## Загрузка файла с помощью `UploadFile`
    
    Определите параметр файла с типом `UploadFile`:
    
    === "Python 3.9+"
    
        ```Python hl_lines="14"
        {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
        ```
    
    === "Python 3.6+"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 15.4K bytes
    - Viewed (0)
  3. docs/de/docs/tutorial/request-files.md

    Aber es gibt viele Fälle, in denen Sie davon profitieren, `UploadFile` zu verwenden.
    
    ## Datei-Parameter mit `UploadFile`
    
    Definieren Sie einen Datei-Parameter mit dem Typ `UploadFile`:
    
    === "Python 3.9+"
    
        ```Python hl_lines="14"
        {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
        ```
    
    === "Python 3.8+"
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 17:58:08 GMT 2024
    - 11.5K bytes
    - Viewed (0)
  4. fastapi/__init__.py

    __version__ = "0.111.0"
    
    from starlette import status as status
    
    from .applications import FastAPI as FastAPI
    from .background import BackgroundTasks as BackgroundTasks
    from .datastructures import UploadFile as UploadFile
    from .exceptions import HTTPException as HTTPException
    from .exceptions import WebSocketException as WebSocketException
    from .param_functions import Body as Body
    from .param_functions import Cookie as Cookie
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:50:18 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  5. docs/en/docs/tutorial/request-files.md

    Keep in mind that this means that the whole contents will be stored in memory. This will work well for small files.
    
    But there are several cases in which you might benefit from using `UploadFile`.
    
    ## File Parameters with `UploadFile`
    
    Define a file parameter with a type of `UploadFile`:
    
    === "Python 3.9+"
    
        ```Python hl_lines="14"
        {!> ../../../docs_src/request_files/tutorial001_an_py39.py!}
        ```
    
    === "Python 3.8+"
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 10.2K bytes
    - Viewed (0)
  6. fastapi/_compat.py

                    return True
        return False
    
    
    def is_uploadfile_or_nonable_uploadfile_annotation(annotation: Any) -> bool:
        if lenient_issubclass(annotation, UploadFile):
            return True
        origin = get_origin(annotation)
        if origin is Union or origin is UnionType:
            for arg in get_args(annotation):
                if lenient_issubclass(arg, UploadFile):
                    return True
        return False
    
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 22.6K bytes
    - Viewed (0)
  7. fastapi/dependencies/utils.py

        get_missing_field_error,
        is_bytes_field,
        is_bytes_sequence_field,
        is_scalar_field,
        is_scalar_sequence_field,
        is_sequence_field,
        is_uploadfile_or_nonable_uploadfile_annotation,
        is_uploadfile_sequence_annotation,
        lenient_issubclass,
        sequence_types,
        serialize_sequence_value,
        value_is_sequence,
    )
    from fastapi.background import BackgroundTasks
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:52:56 GMT 2024
    - 29.5K bytes
    - Viewed (0)
  8. docs/ru/docs/tutorial/request-forms-and-files.md

        ```
    
    Файлы и поля формы будут загружены в виде данных формы, и вы получите файлы и поля формы.
    
    Вы можете объявить некоторые файлы как `bytes`, а некоторые - как `UploadFile`.
    
    !!! warning "Внимание"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 2.9K bytes
    - Viewed (0)
  9. docs/pt/docs/tutorial/request-forms-and-files.md

    ```
    
    Os arquivos e campos de formulário serão carregados como dados de formulário e você receberá os arquivos e campos de formulário.
    
    E você pode declarar alguns dos arquivos como `bytes` e alguns como `UploadFile`.
    
    !!! warning "Aviso"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 1.4K bytes
    - Viewed (0)
  10. docs/zh/docs/tutorial/request-forms-and-files.md

    ```
    
    ## 定义 `File` 与 `Form` 参数
    
    创建文件和表单参数的方式与 `Body` 和 `Query` 一样:
    
    ```Python hl_lines="8"
    {!../../../docs_src/request_forms_and_files/tutorial001.py!}
    ```
    
    文件和表单字段作为表单数据上传与接收。
    
    声明文件可以使用 `bytes` 或 `UploadFile` 。
    
    !!! warning "警告"
    
        可在一个*路径操作*中声明多个 `File` 与 `Form` 参数,但不能同时声明要接收 JSON 的 `Body` 字段。因为此时请求体的编码为 `multipart/form-data`,不是 `application/json`。
    
        这不是 **FastAPI** 的问题,而是 HTTP 协议的规定。
    
    ## 小结
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 1.1K bytes
    - Viewed (0)
Back to top