aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@niklashalle.net>2020-09-18 17:49:19 +0200
committerniklas <niklas@niklashalle.net>2020-09-18 17:49:19 +0200
commit44357d6e6b4f9f7483d4ebfc7226c3b22605f627 (patch)
tree651a7b257b1f74242dcfc790c33f676ab33174a6
parent9a5693bb5dcf70bfaa06504211055a32c9b830b2 (diff)
downloadn_frontend_signal-44357d6e6b4f9f7483d4ebfc7226c3b22605f627.tar.gz
n_frontend_signal-44357d6e6b4f9f7483d4ebfc7226c3b22605f627.zip
"works"
-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