Spaces:
Running
Running
File size: 389 Bytes
1ebbb74 |
1 2 3 4 5 6 7 8 9 10 11 12 |
import os
import tempfile
async def create_temp_file(suffix: str, content: bytes = None, prefix: str = None) -> tempfile.NamedTemporaryFile:
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix, prefix=prefix)
temp_file.delete_file = lambda: os.unlink(temp_file.name)
if content:
temp_file.write(content)
temp_file.close()
return temp_file
|