big b oys
This commit is contained in:
@@ -16,7 +16,7 @@ class Config:
|
||||
|
||||
# File upload configuration
|
||||
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'}
|
||||
|
||||
# Audio upload configuration
|
||||
|
||||
@@ -74,8 +74,14 @@ def import_data():
|
||||
# Save uploaded file to temporary location
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
temp_path = os.path.join(temp_dir, secure_filename(file.filename))
|
||||
|
||||
print(f"Saving uploaded file to: {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
|
||||
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):
|
||||
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:
|
||||
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
|
||||
|
||||
except zipfile.BadZipFile:
|
||||
return False, "Invalid ZIP file format"
|
||||
except json.JSONDecodeError:
|
||||
return False, "Invalid JSON in manifest.json"
|
||||
except zipfile.BadZipFile as e:
|
||||
print(f"BadZipFile error: {e}")
|
||||
return False, f"Invalid ZIP file format: {str(e)}"
|
||||
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:
|
||||
print(f"Unexpected validation error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False, f"Validation error: {str(e)}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user