Spaces:
Sleeping
Sleeping
“vinit5112”
commited on
Commit
·
0a7909d
1
Parent(s):
52b027f
upload issue
Browse files- README.md +8 -2
- backend/backend_api.py +1 -1
- frontend/nginx.conf +11 -0
- frontend/nginx.global.conf +6 -0
- frontend/src/components/FileUploader.js +23 -4
README.md
CHANGED
@@ -73,9 +73,15 @@ If file uploads aren't working, check:
|
|
73 |
|-------|-------|----------|
|
74 |
| Network Error | Server not running | Start backend server |
|
75 |
| 500 Server Error | Missing API keys | Check environment variables |
|
76 |
-
| 413 File Too Large | File exceeds limit |
|
77 |
| 415 Unsupported Type | Wrong file format | Use PDF/DOCX/TXT only |
|
78 |
-
| Timeout | Large file/slow connection |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
### Debug Steps:
|
81 |
1. Run `python backend/diagnostic.py`
|
|
|
73 |
|-------|-------|----------|
|
74 |
| Network Error | Server not running | Start backend server |
|
75 |
| 500 Server Error | Missing API keys | Check environment variables |
|
76 |
+
| 413 File Too Large | File exceeds 100MB limit | Use files smaller than 100MB |
|
77 |
| 415 Unsupported Type | Wrong file format | Use PDF/DOCX/TXT only |
|
78 |
+
| Timeout | Large file/slow connection | Wait longer or use smaller files |
|
79 |
+
|
80 |
+
### File Upload Limits:
|
81 |
+
- **Maximum file size**: 100MB per file
|
82 |
+
- **Supported formats**: PDF, DOCX, TXT
|
83 |
+
- **Recommended size**: Under 10MB for faster processing
|
84 |
+
- **Multiple files**: Can upload multiple files simultaneously
|
85 |
|
86 |
### Debug Steps:
|
87 |
1. Run `python backend/diagnostic.py`
|
backend/backend_api.py
CHANGED
@@ -112,7 +112,7 @@ async def ask_question_stream(request: QuestionRequest):
|
|
112 |
raise HTTPException(status_code=500, detail=f"Error processing streaming question: {str(e)}")
|
113 |
|
114 |
@app.post("/api/upload")
|
115 |
-
async def upload_document(file: UploadFile = File(
|
116 |
"""
|
117 |
Upload a document to the RAG system
|
118 |
"""
|
|
|
112 |
raise HTTPException(status_code=500, detail=f"Error processing streaming question: {str(e)}")
|
113 |
|
114 |
@app.post("/api/upload")
|
115 |
+
async def upload_document(file: UploadFile = File(..., max_length=100*1024*1024)):
|
116 |
"""
|
117 |
Upload a document to the RAG system
|
118 |
"""
|
frontend/nginx.conf
CHANGED
@@ -13,6 +13,11 @@ scgi_temp_path /app/tmp/scgi;
|
|
13 |
server {
|
14 |
listen 7860;
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
# Root directory for the React app
|
17 |
root /usr/share/nginx/html;
|
18 |
index index.html index.htm;
|
@@ -29,6 +34,12 @@ server {
|
|
29 |
proxy_set_header X-Real-IP $remote_addr;
|
30 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
31 |
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
# Cache static assets
|
|
|
13 |
server {
|
14 |
listen 7860;
|
15 |
|
16 |
+
# Increase file upload size limit for document uploads
|
17 |
+
client_max_body_size 100M;
|
18 |
+
client_body_timeout 300s;
|
19 |
+
client_header_timeout 300s;
|
20 |
+
|
21 |
# Root directory for the React app
|
22 |
root /usr/share/nginx/html;
|
23 |
index index.html index.htm;
|
|
|
34 |
proxy_set_header X-Real-IP $remote_addr;
|
35 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
36 |
proxy_set_header X-Forwarded-Proto $scheme;
|
37 |
+
|
38 |
+
# Increase timeouts for large file uploads
|
39 |
+
proxy_connect_timeout 300s;
|
40 |
+
proxy_send_timeout 300s;
|
41 |
+
proxy_read_timeout 300s;
|
42 |
+
proxy_request_buffering off;
|
43 |
}
|
44 |
|
45 |
# Cache static assets
|
frontend/nginx.global.conf
CHANGED
@@ -14,6 +14,12 @@ http {
|
|
14 |
access_log /app/logs/access.log;
|
15 |
error_log /app/logs/error.log warn;
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
sendfile on;
|
18 |
keepalive_timeout 65;
|
19 |
|
|
|
14 |
access_log /app/logs/access.log;
|
15 |
error_log /app/logs/error.log warn;
|
16 |
|
17 |
+
# Global file upload settings
|
18 |
+
client_max_body_size 100M;
|
19 |
+
client_body_buffer_size 1M;
|
20 |
+
client_body_timeout 300s;
|
21 |
+
client_header_timeout 300s;
|
22 |
+
|
23 |
sendfile on;
|
24 |
keepalive_timeout 65;
|
25 |
|
frontend/src/components/FileUploader.js
CHANGED
@@ -25,9 +25,22 @@ const FileUploader = ({ darkMode, onClose }) => {
|
|
25 |
const formData = new FormData();
|
26 |
formData.append('file', file);
|
27 |
|
28 |
-
// Check file size
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
await uploadDocument(formData);
|
@@ -58,7 +71,7 @@ const FileUploader = ({ darkMode, onClose }) => {
|
|
58 |
} else if (error.message.includes('timeout')) {
|
59 |
errorMessage += ': Upload timed out. File may be too large.';
|
60 |
} else if (error.message.includes('413')) {
|
61 |
-
errorMessage += ': File too large
|
62 |
} else if (error.message.includes('415')) {
|
63 |
errorMessage += ': Unsupported file type.';
|
64 |
} else if (error.message.includes('500')) {
|
@@ -133,6 +146,12 @@ const FileUploader = ({ darkMode, onClose }) => {
|
|
133 |
Drag & drop files here, or click to browse
|
134 |
</p>
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
<div className="flex justify-center space-x-2">
|
137 |
<span className={`px-3 py-1 rounded-full text-xs font-medium ${
|
138 |
darkMode
|
|
|
25 |
const formData = new FormData();
|
26 |
formData.append('file', file);
|
27 |
|
28 |
+
// Check file size limits
|
29 |
+
const maxSize = 100 * 1024 * 1024; // 100MB
|
30 |
+
if (file.size > maxSize) {
|
31 |
+
toast.error(`${file.name} is too large (${formatFileSize(file.size)}). Maximum size is 100MB.`);
|
32 |
+
setUploadedFiles(prev => [...prev, {
|
33 |
+
name: file.name,
|
34 |
+
size: file.size,
|
35 |
+
status: 'error',
|
36 |
+
error: 'File too large (max 100MB)'
|
37 |
+
}]);
|
38 |
+
continue; // Skip this file
|
39 |
+
} else if (file.size > 10 * 1024 * 1024) {
|
40 |
+
toast(`Warning: ${file.name} is large (${formatFileSize(file.size)}). Upload may take time.`, {
|
41 |
+
icon: '⚠️',
|
42 |
+
duration: 6000
|
43 |
+
});
|
44 |
}
|
45 |
|
46 |
await uploadDocument(formData);
|
|
|
71 |
} else if (error.message.includes('timeout')) {
|
72 |
errorMessage += ': Upload timed out. File may be too large.';
|
73 |
} else if (error.message.includes('413')) {
|
74 |
+
errorMessage += ': File too large (max 100MB allowed).';
|
75 |
} else if (error.message.includes('415')) {
|
76 |
errorMessage += ': Unsupported file type.';
|
77 |
} else if (error.message.includes('500')) {
|
|
|
146 |
Drag & drop files here, or click to browse
|
147 |
</p>
|
148 |
|
149 |
+
<p className={`text-xs mb-4 ${
|
150 |
+
darkMode ? 'text-gray-500' : 'text-gray-500'
|
151 |
+
}`}>
|
152 |
+
Maximum file size: 100MB
|
153 |
+
</p>
|
154 |
+
|
155 |
<div className="flex justify-center space-x-2">
|
156 |
<span className={`px-3 py-1 rounded-full text-xs font-medium ${
|
157 |
darkMode
|