big b oys
This commit is contained in:
@@ -16,7 +16,7 @@ class Config:
|
|||||||
|
|
||||||
# File upload configuration
|
# File upload configuration
|
||||||
UPLOAD_FOLDER = BASE_DIR / "backend" / "static" / "images"
|
UPLOAD_FOLDER = BASE_DIR / "backend" / "static" / "images"
|
||||||
MAX_CONTENT_LENGTH = 5 * 1024 * 1024 # 5MB max file size
|
MAX_CONTENT_LENGTH = 500 * 1024 * 1024 # 500MB max file size (increased for bulk import/export)
|
||||||
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
|
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
|
||||||
|
|
||||||
# Audio upload configuration
|
# Audio upload configuration
|
||||||
|
|||||||
@@ -74,8 +74,14 @@ def import_data():
|
|||||||
# Save uploaded file to temporary location
|
# Save uploaded file to temporary location
|
||||||
temp_dir = tempfile.mkdtemp()
|
temp_dir = tempfile.mkdtemp()
|
||||||
temp_path = os.path.join(temp_dir, secure_filename(file.filename))
|
temp_path = os.path.join(temp_dir, secure_filename(file.filename))
|
||||||
|
|
||||||
|
print(f"Saving uploaded file to: {temp_path}")
|
||||||
file.save(temp_path)
|
file.save(temp_path)
|
||||||
|
|
||||||
|
# Verify file was saved
|
||||||
|
file_size = os.path.getsize(temp_path)
|
||||||
|
print(f"Saved file size: {file_size} bytes")
|
||||||
|
|
||||||
# Import from ZIP
|
# Import from ZIP
|
||||||
result = import_questions_from_zip(temp_path)
|
result = import_questions_from_zip(temp_path)
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ def validate_import_zip(zip_path: str) -> Tuple[bool, Optional[str]]:
|
|||||||
if not os.path.exists(zip_path):
|
if not os.path.exists(zip_path):
|
||||||
return False, "ZIP file not found"
|
return False, "ZIP file not found"
|
||||||
|
|
||||||
|
# Check file size
|
||||||
|
file_size = os.path.getsize(zip_path)
|
||||||
|
print(f"Validating ZIP file: {zip_path}, size: {file_size} bytes")
|
||||||
|
|
||||||
|
if file_size == 0:
|
||||||
|
return False, "ZIP file is empty"
|
||||||
|
|
||||||
# Try to open as ZIP
|
# Try to open as ZIP
|
||||||
try:
|
try:
|
||||||
with zipfile.ZipFile(zip_path, 'r') as zipf:
|
with zipfile.ZipFile(zip_path, 'r') as zipf:
|
||||||
@@ -214,12 +221,17 @@ def validate_import_zip(zip_path: str) -> Tuple[bool, Optional[str]]:
|
|||||||
|
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
except zipfile.BadZipFile:
|
except zipfile.BadZipFile as e:
|
||||||
return False, "Invalid ZIP file format"
|
print(f"BadZipFile error: {e}")
|
||||||
except json.JSONDecodeError:
|
return False, f"Invalid ZIP file format: {str(e)}"
|
||||||
return False, "Invalid JSON in manifest.json"
|
except json.JSONDecodeError as e:
|
||||||
|
print(f"JSON decode error: {e}")
|
||||||
|
return False, f"Invalid JSON in manifest.json: {str(e)}"
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"Unexpected validation error: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
return False, f"Validation error: {str(e)}"
|
return False, f"Validation error: {str(e)}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user