Save the uploaded file to disk. Args: destination: Destination file path.
(self, destination: str | Path)
| 110 | return None |
| 111 | |
| 112 | async def save(self, destination: str | Path) -> None: |
| 113 | """Save the uploaded file to disk. |
| 114 | |
| 115 | Args: |
| 116 | destination: Destination file path. |
| 117 | """ |
| 118 | path = Path(destination) |
| 119 | try: |
| 120 | await self._upload_file.seek(0) |
| 121 | except Exception: |
| 122 | pass |
| 123 | with path.open("wb") as output: |
| 124 | while True: |
| 125 | chunk = await self._upload_file.read(1024 * 1024) |
| 126 | if not chunk: |
| 127 | break |
| 128 | output.write(chunk) |
| 129 | |
| 130 | async def read(self, size: int = -1) -> bytes: |
| 131 | """Read bytes from the uploaded file. |
no test coverage detected