Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 12 for PNGStreamingResponse (0.13 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. docs_src/stream_data/tutorial002_py310.py

    
    app = FastAPI()
    
    
    class PNGStreamingResponse(StreamingResponse):
        media_type = "image/png"
    
    
    @app.get("/image/stream", response_class=PNGStreamingResponse)
    async def stream_image() -> AsyncIterable[bytes]:
        with read_image() as image_file:
            for chunk in image_file:
                yield chunk
    
    
    @app.get("/image/stream-no-async", response_class=PNGStreamingResponse)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 20:51:40 GMT 2026
    - 5.6K bytes
    - Click Count (0)
  2. fastapi/.agents/skills/fastapi/references/streaming.md

    ```python
    from fastapi import FastAPI
    from fastapi.responses import StreamingResponse
    from app.utils import read_image
    
    app = FastAPI()
    
    
    class PNGStreamingResponse(StreamingResponse):
        media_type = "image/png"
    
    @app.get("/image", response_class=PNGStreamingResponse)
    def stream_image_no_async_no_annotation():
        with read_image() as image_file:
            yield from image_file
    ```
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 10:05:57 GMT 2026
    - 2.5K bytes
    - Click Count (0)
  3. docs/en/docs/advanced/stream-data.md

    One of the main use cases would be to stream `bytes` instead of strings, you can of course do it.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## A Custom `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    In the examples above, the data bytes were streamed, but the response didn't have a `Content-Type` header, so the client didn't know what type of data it was receiving.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 5.4K bytes
    - Click Count (0)
  4. docs/zh/docs/advanced/stream-data.md

    主要的用例之一是流式传输 `bytes` 而不是字符串,这当然可以做到。
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## 自定义 `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    在上面的示例中,虽然按字节流式传输了数据,但响应没有 `Content-Type` 头,因此客户端不知道接收到的数据类型。
    
    你可以创建 `StreamingResponse` 的自定义子类,将 `Content-Type` 头设置为你要流式传输的数据类型。
    
    例如,你可以创建一个 `PNGStreamingResponse`,通过 `media_type` 属性把 `Content-Type` 头设置为 `image/png`:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:29:48 GMT 2026
    - 5.2K bytes
    - Click Count (0)
  5. docs/ja/docs/advanced/stream-data.md

    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## カスタム `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    上記の例ではバイト列をストリームしましたが、レスポンスに `Content-Type` ヘッダがないため、クライアントは受け取るデータの種類を認識できませんでした。
    
    `StreamingResponse` を継承したカスタムクラスを作成し、ストリームするデータに応じて `Content-Type` ヘッダを設定できます。
    
    例えば、`media_type` 属性で `Content-Type` を `image/png` に設定する `PNGStreamingResponse` を作成できます:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:55:22 GMT 2026
    - 6.7K bytes
    - Click Count (0)
  6. docs/ru/docs/advanced/stream-data.md

    Один из основных сценариев — стримить `bytes` вместо строк, и, конечно, это можно сделать.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## Пользовательский `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    В примерах выше байты данных передавались потоком, но в ответе не было HTTP-заголовка `Content-Type`, поэтому клиент не знал, какой тип данных он получает.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:56:20 GMT 2026
    - 8.9K bytes
    - Click Count (0)
  7. docs/es/docs/advanced/stream-data.md

    Uno de los casos de uso principales sería transmitir `bytes` en lugar de strings; por supuesto puedes hacerlo.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## Un `PNGStreamingResponse` personalizado { #a-custom-pngstreamingresponse }
    
    En los ejemplos anteriores, se transmitieron los bytes de datos, pero la response no tenía un header `Content-Type`, así que el cliente no sabía qué tipo de datos estaba recibiendo.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:12:26 GMT 2026
    - 5.7K bytes
    - Click Count (0)
  8. docs/uk/docs/advanced/stream-data.md

    Один з основних сценаріїв - передавати потоком `bytes` замість строк; це, звісно, підтримується.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## Користувацький `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    У наведених вище прикладах байти даних передавалися потоком, але у відповіді не було заголовка `Content-Type`, тому клієнт не знав, який тип даних він отримує.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:25:54 GMT 2026
    - 8.5K bytes
    - Click Count (0)
  9. docs/ko/docs/advanced/stream-data.md

    ## 사용자 정의 `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    위 예시에서는 바이트 데이터를 스트리밍했지만, 응답에 `Content-Type` 헤더가 없어 클라이언트는 어떤 유형의 데이터를 받는지 알 수 없습니다.
    
    스트리밍하는 데이터 유형에 맞춰 `Content-Type` 헤더를 설정하는 `StreamingResponse`의 하위 클래스를 직접 만들 수 있습니다.
    
    예를 들어 `media_type` 속성을 사용해 `Content-Type` 헤더를 `image/png`로 설정하는 `PNGStreamingResponse`를 만들 수 있습니다:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:56:39 GMT 2026
    - 6.2K bytes
    - Click Count (0)
  10. docs/de/docs/advanced/stream-data.md

    Einer der Hauptanwendungsfälle wäre, `bytes` statt Strings zu streamen, das können Sie selbstverständlich tun.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## Eine benutzerdefinierte `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    In den obigen Beispielen wurden die Datenbytes gestreamt, aber die Response hatte keinen `Content-Type`-Header, sodass der Client nicht wusste, welchen Datentyp er erhielt.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 17:48:21 GMT 2026
    - 6K bytes
    - Click Count (0)
Back to Top