acecalisto3 commited on
Commit
475baf9
·
verified ·
1 Parent(s): 35d78ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -11
app.py CHANGED
@@ -152,19 +152,10 @@ class URLProcessor:
152
  class FileProcessor:
153
  """Class to handle file processing"""
154
 
155
- def __init__(self, max_file_size: int = 10 * 1024 * 1024): # 10MB default
156
  self.max_file_size = max_file_size
157
  self.supported_text_extensions = {'.txt', '.md', '.csv', '.json', '.xml'}
158
 
159
- def is_text_file(self, filepath: str) -> bool:
160
- """Check if file is a text file"""
161
- try:
162
- mime_type, _ = mimetypes.guess_type(filepath)
163
- return (mime_type and mime_type.startswith('text/')) or \
164
- (os.path.splitext(filepath)[1].lower() in self.supported_text_extensions)
165
- except Exception:
166
- return False
167
-
168
  def process_file(self, file) -> List[Dict]:
169
  """Process uploaded file with enhanced error handling"""
170
  if not file:
@@ -175,7 +166,7 @@ class FileProcessor:
175
  file_size = os.path.getsize(file.name)
176
  if file_size > self.max_file_size:
177
  logger.warning(f"File size ({file_size} bytes) exceeds maximum allowed size")
178
- return []
179
 
180
  with tempfile.TemporaryDirectory() as temp_dir:
181
  if zipfile.is_zipfile(file.name):
 
152
  class FileProcessor:
153
  """Class to handle file processing"""
154
 
155
+ def __init__(self, max_file_size: int = 2 * 1024 * 1024 * 1024): # 2GB default
156
  self.max_file_size = max_file_size
157
  self.supported_text_extensions = {'.txt', '.md', '.csv', '.json', '.xml'}
158
 
 
 
 
 
 
 
 
 
 
159
  def process_file(self, file) -> List[Dict]:
160
  """Process uploaded file with enhanced error handling"""
161
  if not file:
 
166
  file_size = os.path.getsize(file.name)
167
  if file_size > self.max_file_size:
168
  logger.warning(f"File size ({file_size} bytes) exceeds maximum allowed size")
169
+ return [{"error": f"File size ({file_size} bytes) exceeds maximum allowed size of {self.max_file_size} bytes."}]
170
 
171
  with tempfile.TemporaryDirectory() as temp_dir:
172
  if zipfile.is_zipfile(file.name):