Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 14 for PNGStreamingResponse (0.2 seconds)

  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/zh-hant/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:33:04 GMT 2026
    - 4.9K bytes
    - Click Count (0)
  4. 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)
  5. 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)
  6. 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)
  7. docs/tr/docs/advanced/stream-data.md

    Başlıca kullanım senaryolarından biri string yerine `bytes` akıtmaktır; elbette bunu yapabilirsiniz.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[44:47] hl[47] *}
    
    ## Özel bir `PNGStreamingResponse` { #a-custom-pngstreamingresponse }
    
    Yukarıdaki örneklerde veri baytları akıtıldı, ancak response'ta bir `Content-Type` header'ı yoktu; bu nedenle istemci hangi tür veriyi aldığını bilmiyordu.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:51:35 GMT 2026
    - 5.8K bytes
    - Click Count (0)
  8. 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)
  9. 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)
  10. 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)
Back to Top