The "megosztó" service in this repository is a file-sharing service provided by the Hausz Kft. It allows users to upload, manage, and share files, either publicly or privately, with additional features such as file encryption, access control, and filtering. Here's a detailed breakdown of its functionality:
Core Features
-
File Uploading:
- Users can upload files through the web interface.
- Files can be marked as:
- Private: Only the uploader can view or download the file.
- Members Only: Accessible only to registered and logged-in Hausz members.
- Public: Available to all users.
-
File Listing and Filtering:
- Uploaded files are displayed in a table format.
- Users can filter files by:
- Filename
- Upload date
- Uploader[Redacted Person]
- Hidden or restricted files are not listed for unauthorized users.
-
File Downloading:
- Files can be downloaded based on their access restrictions (e.g., public, private, or members-only).
- Encrypted files require the correct decryption key for access.
-
File Management:
- Files can be renamed by their owners.
- Users can delete their own files.
- Owners can toggle the private/public status or restrict access to members only.
-
Encryption:
- Files can be encrypted during upload.
- Two encryption versions are supported:
- v1: Files are encrypted with a user-provided key.
- v2: Files are encrypted with a pre-generated hash key.
- Encrypted files can only be downloaded and decrypted with the correct key.
-
Storage Status Monitoring:
- Displays the used and available storage on the server.
- Ensures sufficient free space is available before allowing new uploads.
-
File Previewing:
- Supports previewing certain file types (e.g., images, audio, text files) within the browser, provided the file size is below 10 MB.
-
Claim Ownership of Anonymous Files:
- Users can claim ownership of unclaimed (anonymous) files.
Technical Details
-
Frontend:
- HTML, CSS, and JavaScript are used for the web interface.
- Dynamic functionalities are implemented in the
megoszto.ts file, which includes:
- File filtering
- Managing visibility of UI elements based on session state
- Uploading and displaying files in a table format.
-
Backend:
- Implemented in Rust (
megoszto.rs).
- Handles file uploads, downloads, encryption/decryption, and database interactions.
- Uses the
actix-web framework for handling HTTP requests.
- Enforces access control policies and validates file-related metadata.
-
Database:
- Stores metadata about uploaded files, including:
- Filename
- File size
- Ownership (user ID)
- Access restrictions (private/public/members-only)
- Encryption details.
-
Other Features:
- MIME type detection for uploaded files.
- Sanitization of file names to prevent injection attacks.
- Logs file-related activities (e.g., uploads, deletions) for auditing.
User Interface
The service provides a user-friendly interface (megoszto.html) with features such as:
- A drag-and-drop area for file uploads.
- Options to toggle file privacy and member-only access.
- A search and filtering bar to quickly find specific files.
- Indicators for file attributes (e.g., encrypted, private).
Use Cases
- Personal Use: Users can store private files securely.
- Team Collaboration: Share files with other Hausz members through the "members-only" feature.
- Public Sharing: Make files available for download to all users.
Testing
- Automated tests for the service are implemented using Cypress (
megosztó.cy.js). These cover both mobile and desktop views, ensuring the functionality works across different devices.
In summary, the "megosztó" service is a versatile file-sharing platform with robust features for privacy, security (encryption), and usability, catering to both individual and team-based use cases.