- Sort Score
- Result 10 results
- Languages All
Results 31 - 40 of 94 for uploadable (0.17 sec)
-
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+"
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Wed Mar 13 19:02:19 UTC 2024 - 15.4K bytes - Viewed (0) -
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: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 6K bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_03.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: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 6K bytes - Viewed (0) -
docs_src/request_files/tutorial001_02.py
from typing import Union from fastapi import FastAPI, File, UploadFile app = FastAPI() @app.post("/files/") async def create_file(file: Union[bytes, None] = File(default=None)): if not file: return {"message": "No file sent"} else: return {"file_size": len(file)} @app.post("/uploadfile/") async def create_upload_file(file: Union[UploadFile, None] = None): if not file:
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Sat May 14 11:59:59 UTC 2022 - 508 bytes - Viewed (0) -
docs_src/request_forms_and_files/tutorial001.py
from fastapi import FastAPI, File, Form, UploadFile app = FastAPI() @app.post("/files/") async def create_file( file: bytes = File(), fileb: UploadFile = File(), token: str = Form() ): return { "file_size": len(file), "token": token, "fileb_content_type": fileb.content_type,
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 317 bytes - Viewed (0) -
docs_src/request_forms_and_files/tutorial001_an_py39.py
from typing import Annotated from fastapi import FastAPI, File, Form, UploadFile app = FastAPI() @app.post("/files/") async def create_file( file: Annotated[bytes, File()], fileb: Annotated[UploadFile, File()], token: Annotated[str, Form()], ): return { "file_size": len(file), "token": token, "fileb_content_type": fileb.content_type,
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 386 bytes - Viewed (0) -
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
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Thu May 02 22:50:18 UTC 2024 - 1.1K bytes - Viewed (0) -
docs_src/request_files/tutorial003_an_py39.py
from fastapi import FastAPI, File, UploadFile from fastapi.responses import HTMLResponse app = FastAPI() @app.post("/files/") async def create_files( files: Annotated[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: Annotated[
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 952 bytes - Viewed (0) -
docs/ko/docs/tutorial/request-files.md
이것은 전체 내용이 메모리에 저장된다는 것을 의미한다는 걸 염두하기 바랍니다. 이는 작은 크기의 파일들에 적합합니다. 어떤 경우에는 `UploadFile` 을 사용하는 것이 더 유리합니다. ## `File` 매개변수와 `UploadFile` `File` 매개변수를 `UploadFile` 타입으로 정의합니다: ```Python hl_lines="12" {!../../../docs_src/request_files/tutorial001.py!} ``` `UploadFile` 을 사용하는 것은 `bytes` 과 비교해 다음과 같은 장점이 있습니다: * "스풀 파일"을 사용합니다. * 최대 크기 제한까지만 메모리에 저장되며, 이를 초과하는 경우 디스크에 저장됩니다.
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Wed Mar 13 19:02:19 UTC 2024 - 8.1K bytes - Viewed (0) -
tests/test_tutorial/test_request_files/test_tutorial001_02_an_py39.py
assert response.status_code == 200, response.text assert response.json() == {"message": "No file sent"} @needs_py39 def test_post_uploadfile_no_body(client: TestClient): response = client.post("/uploadfile/") assert response.status_code == 200, response.text assert response.json() == {"message": "No upload file sent"} @needs_py39 def test_post_file(tmp_path: Path, client: TestClient):
Registered: Mon Jun 17 08:32:26 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 8.5K bytes - Viewed (0)