def store_temp_file(fd):
"""
Given a file-like object and dumps it to the temporary directory.
Returns the temporary file object.
"""
temp_file = tempfile.NamedTemporaryFile(
encoding=getattr(fd, 'encoding', None))
source = FileWrapper(fd)
for chunk in source.chunks():
temp_file.write(chunk)
temp_file.seek(0)
return temp_file
评论列表
文章目录