|
import tempfile |
|
import os |
|
|
|
class FileManager: |
|
@staticmethod |
|
def create_temp_file(content: bytes, suffix: str = ".bin") -> str: |
|
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix) |
|
temp_file.write(content) |
|
temp_file.close() |
|
return temp_file.name |
|
|
|
@staticmethod |
|
def create_temp_path(suffix: str = ".bin") -> str: |
|
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix) |
|
temp_file.close() |
|
return temp_file.name |
|
|
|
@staticmethod |
|
def cleanup_file(file_path: str): |
|
if os.path.exists(file_path): |
|
os.remove(file_path) |
|
|