Lebiru.FileService is a simple ASP.NET Core application that allows users to upload, download, and manage files. It provides a RESTful API for file operations and includes a web interface for easy interaction.
- Secure Authentication: 🔒 Admin authentication required to access all features and endpoints.
- File Upload: Users can upload files to the server.
- File Download: Users can download files from the server.
- File Printing: 🖨️ Users can easily print files directly from the web interface.
- File Rename: 🔄 Users can rename their uploaded files while preserving file extensions.
- File Copy: 📋 Users can create copies of files with automatic naming (adds "Copy" suffix).
- File Checksums: 🔐 Users can copy SHA-256 checksums of files to the clipboard for verification.
- Multi-File Download to Zip: Users can download multiple files into a zip from the server. (@alfcanres)
- File Listing: Users can view a list of uploaded files along with their upload times.
- Image Preview: 🖼️ Image files are displayed with a preview in the web interface.
- Text File Preview: 📄 Text files show the first 100 characters as a preview in the web interface.
- File Type Icons: 📂 Files are displayed with appropriate Font Awesome icons based on file type.
- Local Time Display: 🕒 Upload times automatically displayed in user's local timezone with AM/PM format.
- File Expiry: ⏳ Set expiration times for uploaded files (1 minute, 1 hour, 1 day, 1 week, or never).
- Sidebar Navigation: 📋 Permanent sidebar navigation for easy access to all application features.
- MIME Type Validation: 🛡️ Security feature that validates file MIME types during upload to prevent malicious files.
- Enhanced Upload Interface: 📤 Dedicated upload page with drag-and-drop functionality for easier file uploads.
- Background Jobs: 🔄 Automated cleanup of expired files using Hangfire.
- Job Monitoring: 📊 Hangfire dashboard for monitoring file cleanup and expiry jobs.
- Console Logging: 📝 Detailed logging of file deletions and cleanup operations.
- Dark Mode: 🌙 Toggle between light and dark themes for better visibility.
- User Management: 👥 Multi-user support with different roles (Admin/Contributor/Viewer).
- File Ownership: 📋 Track file ownership and permissions per user.
- API Metrics: 📈 Track usage metrics (uploads, downloads, deletions) with last update time.
- Data Persistence: 💾 All data (user info, metrics, file info) persisted in app-data directory.
- Bulk Operations: 🗑️ Support for operations like "Delete All Files" with proper cleanup.
- File Sharing: 🔗 Share button to easily copy file viewing links to clipboard.
- In-Browser Text Viewing: 📄 Text files displayed in browser with syntax highlighting and line numbers.
- External File Fetching: 🌐 Fetch files from external sources (FTP, SFTP, HTTP/HTTPS, WebDAV, Network Shares).
- File Transformation: 🔄 Transform files using regex patterns to extract and process content.
-
ASP.NET Core: Backend framework for building web applications and APIs.
-
C#: Programming language used in conjunction with ASP.NET Core.
-
HTML/CSS/JavaScript: Frontend technologies for building the web interface.
-
Swagger: API documentation tool used to document the RESTful API endpoints.
-
Hangfire: Background job processing for scheduled tasks
-
Hangfire.Console: Enhanced logging for background jobs
To run the application locally, follow these steps:
- Clone this repository to your local machine.
- Open the solution in Visual Studio or your preferred IDE.
- Build the solution to restore dependencies.
- Run the application using the IDE's built-in tools or command-line interface.
- Access the application through the provided URL (e.g.,
http://localhost:port).
The project includes a comprehensive test suite. To run the tests and generate a coverage report:
- Run the tests with coverage:
dotnet test --collect:"XPlat Code Coverage"- Generate an HTML report (replace the coverage GUID with your actual generated GUID):
cd Lebiru.FileService.Tests
reportgenerator -reports:"TestResults\{guid}\coverage.cobertura.xml" -targetdir:"coveragereport" -reporttypes:HtmlThe HTML report will be generated in the Lebiru.FileService.Tests\coveragereport directory. Open index.html in your browser to view a detailed breakdown of code coverage across the project.
The API documentation is available through Swagger. Once the application is running, you can access the Swagger UI by navigating to /swagger in your browser.
- The application requires authentication for all features
- Three user roles are available:
- Admin: Full access to all features including user management
- Contributor: Can upload and manage files
- Viewer: Can view and download files
- Default users are created at first startup with generated passwords:
admin(Admin role)contributor(Contributor role)viewer(Viewer role)
- Passwords are displayed in the console at first startup
- All API endpoints and web interfaces require authentication
- Current user is displayed in the navigation bar
- Authentication: All access requires valid credentials with appropriate role permissions
- MIME Type Validation: Both client-side and server-side validation prevents upload of potentially dangerous files
- File Extension Filtering: Blocks known dangerous file extensions (.exe, .bat, .cmd, etc.)
The application supports fetching files from various external sources:
- Multiple Source Types: Connect to FTP, SFTP, HTTP/HTTPS, WebDAV, and Network Shares
- Scheduled Fetching: Configure automatic fetching at regular intervals
- Connection Testing: Test connections before saving fetch sources
- Fetch Activity Tracking: Monitor fetch operations with detailed logs
- File Filtering: Specify patterns to fetch only relevant files
- Post-Fetch Actions: Optionally delete files from source after successful fetch
- Role-Based Access: Different permissions for Admin, Contributor, and Viewer roles
- File Ownership: Users can only modify or delete their own files unless they have Admin privileges
The application provides ETL (Extract, Transform, Load) capabilities for processing files:
- Regex Parsing: Extract specific content from files using regular expressions
- File Pattern Matching: Target specific files for transformation using wildcards
- Scheduled Transformations: Automatically run transformations at configured intervals
- Transform Activity Tracking: Monitor all transform operations with detailed logs
- Test Feature: Test transformations on actual files before saving
- Output Files: Transformed content saved as new files for further processing
- Data Validation: Input validation throughout the application prevents injection attacks
- Uploading Files:
- Use the dedicated upload page with drag-and-drop functionality or the file selector
- Real-time MIME type validation secures against malicious file uploads
- Visual feedback shows validation status for each file being uploaded
- Set expiry time during upload (1 minute, 1 hour, 1 day, 1 week, or never)
- Files are automatically deleted when they expire
- Files are associated with the uploading user
- Progress indicator shows upload status
- Downloading Files:
- Click the download link in the web interface or send a GET request to
/File/DownloadFile?filename=your_file_name - Batch download multiple files as a ZIP archive
- Downloads are tracked in API metrics
- Click the download link in the web interface or send a GET request to
- Printing Files:
- Use the Print button in the file actions menu to open the browser's print dialog
- Optimized print layout for different file types (images, PDFs, text)
- Print directly from the application without downloading files first
- Renaming Files:
- Click the Rename button in the file actions menu to rename files
- File extension is automatically preserved to maintain file type
- Only file owners and admins can rename files
- All references to the file are updated automatically (ownership records, file metadata)
- Copying Files:
- Use the Make Copy button in the file actions menu to duplicate files
- Automatically appends " Copy" to the filename (or " Copy N" if needed for uniqueness)
- Creates a new file with same content and attributes as the original
- New copy is assigned to the user who created it
- File references are automatically updated (ownership records, file metadata)
- File Checksums:
- Click the Copy Checksum button in the file actions menu to copy the SHA-256 hash to clipboard
- Verify file integrity and authenticity by comparing checksums
- Success notification displayed when checksum is copied
- Access via API endpoint at
/File/Checksum?filename=your_file_name
- File Management:
- View list of all uploaded files with upload times and expiry status
- Rename files while preserving file extension and ownership
- See remaining time before file expiry
- Automatic cleanup of expired files
- Share files easily by copying view links to clipboard
- Monitor file operations through Hangfire dashboard at
/hangfire - "Delete All Files" feature for admins with proper cleanup of all related data
- View text files directly in browser with syntax highlighting and line numbers
- User Interface:
- Permanent sidebar navigation for quick access to all app features
- Image previews for supported formats (PNG, JPG, GIF, BMP)
- Click previews to view full-size images
- Toggle dark mode for comfortable viewing
- Search and filter files
- Sort files by various criteria (name, size, upload time, expiry)
- API metrics dashboard showing usage statistics
- Server space usage monitoring
- Real-time file validation feedback during uploads
- Custom error pages that maintain consistent application layout
- Share files easily by copying viewing links to clipboard
- In-browser text file viewing with syntax highlighting and line numbers
The application can be run as a Docker container using the following command:
docker run -d --name fs -p 3000:8080 lebiru/fileserviceThis command will:
- Pull the
lebiru/fileserviceimage from Docker Hub if it's not already available locally - Run the container in detached mode (
-d) - Name the container
fs(--name fs) - Map port 3000 on the host to port 8080 in the container (
-p 3000:8080)
After running this command, you can access the application at http://localhost:3000 in your web browser.
Contributions are welcome! If you have any ideas, improvements, or bug fixes, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
