Overview
DoctorSoft+ provides a comprehensive file management system for handling patient documents, medical images, lab results, and other files. The system includes automatic image compression, thumbnail generation, file descriptions, and secure storage.FileUpload component
TheFileUpload component (src/components/FileUpload.tsx) handles file uploads with validation, compression, and storage.
Basic usage
Configuration options
onFilesUploaded
onFilesUploaded
Callback function called after files are successfully uploaded. Receives an array of uploaded file objects.
initialFiles
initialFiles
Array of previously uploaded files to display. Useful for editing existing records.
maxFiles
maxFiles
Maximum number of files allowed. Default: 5.
maxFileSize
maxFileSize
Maximum file size in MB. Default: 10MB (from environment variable).
acceptedTypes
acceptedTypes
Array of accepted MIME types. Default: images (JPEG, PNG, GIF), PDFs, Word documents, and text files.
bucketName
bucketName
Supabase storage bucket name. Default: from environment variable.
folder
folder
Folder path within the bucket. Format:
patients/{patientId}.enableImageCompression
enableImageCompression
Enable automatic image compression. Default: true.
imageCompressionOptions
imageCompressionOptions
Configuration for image compression:
maxSizeMB: Target file size (default: 1MB)maxWidthOrHeight: Maximum dimension (default: 1920px)useWebWorker: Use web worker for compression (default: true)
File upload flow
File selection
Users can select files by:
- Clicking the upload area to open file browser
- Dragging and dropping files onto the upload area
Validation
Files are validated for:
- File size (must be under
maxFileSize) - File type (must be in
acceptedTypes) - Total file count (must not exceed
maxFiles) - Patient selection (patient ID required)
Image compression
If enabled, JPEG and PNG images are automatically compressed:
- Target size: 1MB (configurable)
- Max dimensions: 1920px (configurable)
- Compression runs in web worker to avoid blocking UI
Upload to storage
Files are uploaded to Supabase Storage:
- Unique filename generated:
{timestamp}-{random}.{extension} - Stored in:
{folder}/{filename} - Public URL generated for access
Thumbnail generation
Thumbnails are automatically created:
- For images: 300px thumbnail with 0.6 quality
- For PDFs: First page rendered as 300x400 JPEG
- Stored in:
thumbnails/{folder}/thumb_{filename}
Supported file types
Default accepted file types:| Type | MIME Types | Use Case |
|---|---|---|
| Images | image/jpeg, image/png, image/gif | X-rays, scans, photos |
application/pdf | Lab results, reports | |
| Word | application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document | Medical reports |
| Text | text/plain | Notes, text documents |
Image compression
Automatic image compression reduces storage costs and improves performance:How it works
File descriptions
DoctorSoft+ requires descriptions for all uploaded files to improve organization:Description modal
When files are selected, a modal appears:Descriptions are stored as the file’s display name in the database, making files easier to identify.
Session validation
File uploads validate the user’s session before proceeding:Patient file gallery
ThePatientFileGallery component displays uploaded files in a visual grid.
Gallery features
Thumbnail display
Files are shown with thumbnails:
- Images: Compressed thumbnail preview
- PDFs: First page thumbnail
- Other files: File type icon
Implementing the gallery
Viewing files
Files can be viewed directly in the application:Image preview
Image preview modal
Image preview modal
Images open in a modal with:
- Full-size image display
- Zoom controls
- Download option
- Close button
PDF and document viewing
PDF and document viewing
PDFs and documents open in a new browser tab for viewing and download.
Deleting files
Files can be deleted with logical deletion:Files are marked as deleted in the database but not physically removed from storage, allowing for recovery if needed.
Drag and drop
The upload component supports drag and drop:Error handling
Comprehensive error handling for file operations:Validation errors
Upload errors
Best practices
Enable image compression
Reduce storage costs and improve performance by enabling compression for medical images.
Require meaningful descriptions
Encourage users to provide clear, medical-context descriptions like “Rayos X de rodilla” instead of generic filenames.
Set appropriate file size limits
Balance between quality and storage:
- X-rays and scans: 5-10MB
- Documents: 2-5MB
- Photos: 2-3MB