File size: 636 Bytes
6220346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)