$ show valor-software/ng2-file-upload
ng2-file-upload is an Angular library providing drag-and-drop and file selection directives for file upload. It consists of two directives (ng2FileSelect and ng2FileDrop) and a core FileUploader class that manages a queue of FileItems, handles XHR uploads with multipart or streaming (disableMultipart), and offers filter-based validation (file size, mime type, file type, queue limit). The demo application showcases standard usage with a remote API. The library is actively maintained with support for Angular 21, but its code style predates modern standalone components and uses legacy Angular patterns (non-standalone directives, manual DI via inject()). Tooling uses Nx 22, Jest, and ng-packagr. While functional and battle-tested (1899 stars), the codebase shows medium technical drift due to reliance on deprecated Angular patterns and a monolithic FileUploader class.
The LLM identified 2 files worth highlighting for reuse:
A pure static class with no Angular dependencies that maps MIME types and file extensions to high-level categories (image, video, audio, pdf, compress, doc, xls, ppt). The getMimeClass and fileTypeDetection methods are self-contained, require no internal state or external imports, and can be extracted into any JavaScript/TypeScript project to classify files based on name or MIME type. This demonstrates clean separation of concerns and a reusable utility pattern.
A wrapper class that normalizes a File object or an HTMLInputElement into a consistent structure with lastModifiedDate, size, type, and name properties. It handles both real File objects and fake path strings (e.g., from input value in older browsers), making it a reusable adapter for file-like data sources. The class has no dependencies and can be extracted and used in any file handling scenario.