- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 25 for uploadFile (0.05 sec)
-
tests/test_request_params/test_file/test_optional_list.py
@app.post("/optional-list-uploadfile") async def read_optional_list_uploadfile( p: Annotated[Optional[list[UploadFile]], File()] = None, ): return {"file_size": [file.size for file in p] if p else None} @pytest.mark.parametrize( "path", [ "/optional-list-bytes", "/optional-list-uploadfile", ], ) def test_optional_list_schema(path: str):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 10.4K bytes - Viewed (0) -
tests/test_request_params/test_file/test_optional.py
return {"file_size": len(p) if p else None} @app.post("/optional-uploadfile", operation_id="optional_uploadfile") async def read_optional_uploadfile(p: Annotated[Optional[UploadFile], File()] = None): return {"file_size": p.size if p else None} @pytest.mark.parametrize( "path", [ "/optional-bytes", "/optional-uploadfile", ], ) def test_optional_schema(path: str):Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 9.7K bytes - Viewed (0) -
tests/test_request_params/test_file/test_list.py
@app.post("/list-uploadfile", operation_id="list_uploadfile") async def read_list_uploadfile(p: Annotated[list[UploadFile], File()]): return {"file_size": [file.size for file in p]} @pytest.mark.parametrize( "path", [ "/list-bytes", "/list-uploadfile", ], ) def test_list_schema(path: str): openapi = app.openapi()
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:31:34 UTC 2025 - 11.2K bytes - Viewed (0) -
tests/test_request_params/test_file/test_required.py
@app.post("/required-uploadfile", operation_id="required_uploadfile") async def read_required_uploadfile(p: Annotated[UploadFile, File()]): return {"file_size": p.size} @pytest.mark.parametrize( "path", [ "/required-bytes", "/required-uploadfile", ], ) def test_required_schema(path: str): openapi = app.openapi() body_model_name = get_body_model_name(openapi, path)
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 10.8K bytes - Viewed (0) -
docs/es/docs/tutorial/request-files.md
Pero hay varios casos en los que podrías beneficiarte de usar `UploadFile`. ## Parámetros de Archivo con `UploadFile` { #file-parameters-with-uploadfile } Define un parámetro de archivo con un tipo de `UploadFile`: {* ../../docs_src/request_files/tutorial001_an_py39.py hl[14] *} Usar `UploadFile` tiene varias ventajas sobre `bytes`:Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Tue Dec 16 16:33:45 UTC 2025 - 7.9K bytes - Viewed (0) -
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 Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 20 15:55:38 UTC 2025 - 1.8K bytes - Viewed (0) -
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 Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 5.1K bytes - Viewed (0) -
docs_src/request_files/tutorial001_03_py39.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 Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 371 bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_03.py
def test_post_upload_file(tmp_path, client: TestClient): path = tmp_path / "test.txt" path.write_bytes(b"<file content>") 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(client: TestClient):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 6.2K bytes - Viewed (0) -
fastapi/_compat/shared.py
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 def is_bytes_sequence_annotation(annotation: Any) -> bool:
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 12:54:56 UTC 2025 - 6.7K bytes - Viewed (0)