Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 70 for uploadable (0.08 sec)

  1. docs/pt/docs/tutorial/request_files.md

    Mas existem vários casos em que você pode se beneficiar ao usar `UploadFile`.
    
    ## Parâmetros de arquivo com `UploadFile`
    
    Defina um parâmetro de arquivo com o tipo `UploadFile`
    
    //// tab | Python 3.9+
    
    ```Python hl_lines="14"
    {!> ../../docs_src/request_files/tutorial001_an_py39.py!}
    ```
    
    ////
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 10.8K bytes
    - Viewed (0)
  2. docs_src/request_files/tutorial001_03_an_py39.py

    from typing import Annotated
    
    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]):
        return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(
        file: Annotated[UploadFile, File(description="A file read as UploadFile")],
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 421 bytes
    - Viewed (0)
  3. tests/test_multipart_installation.py

    import warnings
    
    import pytest
    from fastapi import FastAPI, File, Form, UploadFile
    from fastapi.dependencies.utils import (
        multipart_incorrect_install_error,
        multipart_not_installed_error,
    )
    
    
    def test_incorrect_multipart_installed_form(monkeypatch):
        monkeypatch.setattr("python_multipart.__version__", "0.0.12")
        with warnings.catch_warnings(record=True):
            warnings.simplefilter("always")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 27 21:46:26 UTC 2024
    - 5.7K bytes
    - Viewed (0)
  4. tests/test_compat.py

        # For coverage
        # TODO: in theory this would allow declaring types that could be lists of UploadFile
        # and other types, but I'm not even sure it's a good idea to support it as a first
        # class "feature"
        assert is_uploadfile_sequence_annotation(Union[List[str], List[UploadFile]])
    
    
    def test_is_pv1_scalar_field():
        # For coverage
        class Model(BaseModel):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Sep 11 07:45:30 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  5. tests/test_datastructures.py

        app = FastAPI()
    
        testing_file_store: List[UploadFile] = []
    
        @app.post("/uploadfile/")
        def create_upload_file(file: UploadFile):
            testing_file_store.append(file)
            return {"filename": file.filename}
    
        client = TestClient(app)
        with path.open("rb") as file:
            response = client.post("/uploadfile/", files={"file": file})
        assert response.status_code == 200, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 18 12:36:40 UTC 2023
    - 2K bytes
    - Viewed (0)
  6. docs_src/request_files/tutorial001_02_an_py310.py

    from typing import Annotated
    
    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes | None, File()] = None):
        if not file:
            return {"message": "No file sent"}
        else:
            return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(file: UploadFile | None = None):
        if not file:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 505 bytes
    - Viewed (0)
  7. docs_src/request_files/tutorial003_py39.py

    from fastapi import FastAPI, File, UploadFile
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_files(
        files: list[bytes] = File(description="Multiple files as bytes"),
    ):
        return {"file_sizes": [len(file) for file in files]}
    
    
    @app.post("/uploadfiles/")
    async def create_upload_files(
        files: list[UploadFile] = File(description="Multiple files as UploadFile"),
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 888 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_request_files/test_tutorial001_03_an.py

    
    def test_post_upload_file(tmp_path):
        path = tmp_path / "test.txt"
        path.write_bytes(b"<file content>")
    
        client = TestClient(app)
        with path.open("rb") as file:
            response = client.post("/uploadfile/", files={"file": file})
        assert response.status_code == 200, response.text
        assert response.json() == {"filename": "test.txt"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 6K bytes
    - Viewed (0)
  9. fastapi/datastructures.py

        ```python
        from typing import Annotated
    
        from fastapi import FastAPI, File, UploadFile
    
        app = FastAPI()
    
    
        @app.post("/files/")
        async def create_file(file: Annotated[bytes, File()]):
            return {"file_size": len(file)}
    
    
        @app.post("/uploadfile/")
        async def create_upload_file(file: UploadFile):
            return {"filename": file.filename}
        ```
        """
    
        file: Annotated[
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Apr 02 02:48:51 UTC 2024
    - 5.6K bytes
    - Viewed (0)
  10. docs_src/request_files/tutorial001_03.py

    from fastapi import FastAPI, File, UploadFile
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: bytes = File(description="A file read as bytes")):
        return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(
        file: UploadFile = File(description="A file read as UploadFile"),
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri May 13 23:38:22 UTC 2022
    - 371 bytes
    - Viewed (0)
Back to top