aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmain.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/main.py b/main.py
index ecb649a..4ba4aea 100755
--- a/main.py
+++ b/main.py
@@ -2,6 +2,7 @@
import os
import sys
+import uuid
import base64
import getopt
import requests
@@ -58,12 +59,14 @@ def handle_replies(replies):
elif a_type == "attachment":
[file_name, file_type, file_content] = a_extra.split(';')
try:
- tmp_path = tempfile.TemporaryDirectory()
+ tmp_path = "/tmp/" + str(uuid.uuid1())
+ os.mkdir(tmp_path)
+ # hack, do clean
file_content = base64.b64decode(file_content)
- file_path = tmp_path.name + '/' + file_name
+ file_path = tmp_path + '/' + file_name
with open(file_path, "wb") as f:
f.write(file_content)
- return answer, True
+ return file_path, True
except Exception as e:
print(str(e))
answer += l_answer