mirror of
https://bitbucket.org/atlassian-docker/docker-atlassian-confluence-server.git
synced 2024-08-30 18:22:16 +00:00
23 lines
582 B
Python
23 lines
582 B
Python
|
import os
|
||
|
import mimetypes
|
||
|
import tempfile
|
||
|
|
||
|
|
||
|
def create_temp_files():
|
||
|
f = tempfile.NamedTemporaryFile(delete=False)
|
||
|
f.write(b"This temporary file is created by file_helper!\n")
|
||
|
f.close()
|
||
|
content_type, encoding = mimetypes.guess_type(f.name)
|
||
|
if content_type is None:
|
||
|
content_type = 'multipart/form-data'
|
||
|
files = {'file': (f.name, open(f.name, 'rb'), content_type)}
|
||
|
|
||
|
return files
|
||
|
|
||
|
|
||
|
def remove_temp_files(files):
|
||
|
if(len(files['file']) > 1):
|
||
|
os.remove(files['file'][0])
|
||
|
return not os.path.exists(files['file'][0])
|
||
|
return True
|