Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -8,7 +8,6 @@ import shutil
|
|
8 |
import tempfile
|
9 |
import requests
|
10 |
import json
|
11 |
-
import py7zr # Import the py7zr library
|
12 |
|
13 |
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
14 |
UPLOAD_FOLDER = os.path.join(BASE_DIR, "uploads")
|
@@ -253,13 +252,14 @@ def process_request(request):
|
|
253 |
)
|
254 |
|
255 |
# Create a .7z archive with ultra compression and LZMA2
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
|
|
260 |
|
261 |
# Return the .7z file in the response
|
262 |
-
return send_file(
|
263 |
|
264 |
except Exception as e:
|
265 |
current_app.logger.error(f"An error occurred: {str(e)}")
|
|
|
8 |
import tempfile
|
9 |
import requests
|
10 |
import json
|
|
|
11 |
|
12 |
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
|
13 |
UPLOAD_FOLDER = os.path.join(BASE_DIR, "uploads")
|
|
|
252 |
)
|
253 |
|
254 |
# Create a .7z archive with ultra compression and LZMA2
|
255 |
+
archive_name = generate_random_string() + ".7z"
|
256 |
+
archive_path = os.path.join(temp_dir, archive_name)
|
257 |
+
subprocess.run([
|
258 |
+
"7z", "a", "-t7z", "-mx=9", "-m0=LZMA2", archive_path, modified_pe_path
|
259 |
+
], check=True)
|
260 |
|
261 |
# Return the .7z file in the response
|
262 |
+
return send_file(archive_path, as_attachment=True, download_name=archive_name)
|
263 |
|
264 |
except Exception as e:
|
265 |
current_app.logger.error(f"An error occurred: {str(e)}")
|