Implementation function to read a file in binary mode. Returns base64 encoded content for RFC transport.
(file_path: str)
| 344 | # ===================================================== |
| 345 | |
| 346 | def _read_file_binary_impl(file_path: str) -> str: |
| 347 | """ |
| 348 | Implementation function to read a file in binary mode. |
| 349 | Returns base64 encoded content for RFC transport. |
| 350 | """ |
| 351 | if not os.path.exists(file_path): |
| 352 | raise FileNotFoundError(f"File not found: {file_path}") |
| 353 | |
| 354 | if not os.path.isfile(file_path): |
| 355 | raise Exception(f"Path is not a file: {file_path}") |
| 356 | |
| 357 | try: |
| 358 | with open(file_path, 'rb') as file: |
| 359 | content = file.read() |
| 360 | return base64.b64encode(content).decode('utf-8') |
| 361 | except Exception as e: |
| 362 | raise Exception(f"Failed to read file {file_path}: {str(e)}") |
| 363 | |
| 364 | |
| 365 | def _write_file_binary_impl(file_path: str, b64_content: str) -> bool: |