Fix large file preview and download issues

- Add persistent Docker volume for file storage to fix 404 download errors
- Set FILE_STORAGE_PATH env var in Dockerfile and docker-compose.yml
- Increase thumbnail generation limit from 500KB to 10MB for images
- Remove encodeURIComponent from file download URL to prevent path encoding

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
michael 2026-01-25 08:06:41 -06:00
parent 687edb547c
commit 907c3a520e
4 changed files with 10 additions and 3 deletions

View file

@ -28,6 +28,9 @@ COPY reference_docs/ ./reference_docs/
# Set reference docs path for container
ENV REFERENCE_DOCS_PATH=/app/reference_docs
# Set file storage path for container
ENV FILE_STORAGE_PATH=/app/storage
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

View file

@ -148,9 +148,9 @@ async def handle_analyze_message(
file_type=file_type,
)
# Generate thumbnail for small files
# Generate thumbnail for images up to 10MB (data URLs are ~33% larger than binary)
thumbnail_url = None
if len(file_data) < 500000: # < 500KB
if len(file_data) < 10000000 and file_type.startswith('image/'):
thumbnail_url = await storage_service.generate_thumbnail_data_url(file_data, file_type)
# Save proof and version

View file

@ -29,6 +29,9 @@ services:
- HOST=0.0.0.0
- PORT=8000
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-modcomms}:${POSTGRES_PASSWORD:-modcomms_dev}@postgres:5432/${POSTGRES_DB:-modcomms}
- FILE_STORAGE_PATH=/app/storage
volumes:
- file_storage:/app/storage
depends_on:
postgres:
condition: service_healthy
@ -42,3 +45,4 @@ services:
volumes:
postgres_data:
file_storage:

View file

@ -184,7 +184,7 @@ class ApiService {
async getFile(storageKey: string): Promise<File> {
const headers = await this.getHeaders();
const response = await fetch(`${API_URL}/api/files/${encodeURIComponent(storageKey)}`, { headers });
const response = await fetch(`${API_URL}/api/files/${storageKey}`, { headers });
if (!response.ok) {
throw new Error(`Failed to fetch file: HTTP ${response.status}`);
}