Now the system work with big files

master
kirbylife 2020-12-09 15:29:45 -06:00
parent 397d911a5d
commit 911652fa2b
2 changed files with 6 additions and 2 deletions

View File

@ -13,6 +13,7 @@ from random import randint
from shutil import rmtree from shutil import rmtree
from threading import Thread from threading import Thread
from time import sleep from time import sleep
from uuid import uuid4
from PIL import Image, ImageTk from PIL import Image, ImageTk
from requests import post from requests import post
@ -182,8 +183,12 @@ class MunyalClient(Icon):
directory = os.path.split(full_path)[0] directory = os.path.split(full_path)[0]
if not os.path.exists(directory): if not os.path.exists(directory):
os.makedirs(directory, exist_ok=True) os.makedirs(directory, exist_ok=True)
with open(full_path, "wb") as f: directory, _ = os.path.split(full_path)
temp_name = str(uuid4()) + ".tmp"
temp_dir = path_join(directory, temp_name)
with open(temp_dir, "wb") as f:
f.write(base64.b85decode(data["file"].encode("ascii"))) f.write(base64.b85decode(data["file"].encode("ascii")))
os.rename(temp_dir, full_path)
else: else:
os.remove(full_path) os.remove(full_path)
else: else:
@ -192,7 +197,6 @@ class MunyalClient(Icon):
else: else:
shutil.rmtree(full_path) shutil.rmtree(full_path)
def __download(self, message): def __download(self, message):
try: try:
data = json.loads(message) data = json.loads(message)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 101 KiB