def _make_temp_file_for_upload(self, upload):
fname = os.path.join(tempfile.tempdir,
"{0}-{1}".format(random.randint(0, 1000000),
upload.filename))
with open(fname, "wb") as f:
f.write(upload.content)
def rmfile():
os.unlink(fname)
self.addCleanup(rmfile)
return fname
评论列表
文章目录