Hi Yida,
In this case i would recommend to use a Bytes Buffer (BytesIO()) instead of a NamedTempFile()
The difference is that Tempfile is saved on the HDD/SDD, where a BytesIO buffer is kept only in RAM memory. A BytesIO object can be seen as a file only existing in RAM memory.
from io import BytesIO
def arc_factsheet_to_viktor_file(arcadis_factsheet: Document) -> File:
# Create empty Bytes buffer
bytes_buffer = BytesIO()
# save file in the Bytes buffer
factsheet = arcadis_factsheet.save(bytes_buffer)
# Create VIKTOR File object from Bytes buffer
file = File.from_data(bytes_buffer.getvalue())
return file
I hope this helps.
edited after @yida.tao her comment