- Does this package work with Laravel 10.x or older versions?
- No, **anil/file-picker** requires **Laravel 11.x, 12.x, or 13.x** and **Livewire 3.x or 4.x**. If you’re on an older version, you’ll need to upgrade or explore alternatives like custom Livewire components or standalone file-upload libraries.
- How do I integrate this into an existing Livewire app with custom file upload logic?
- The package replaces or augments existing upload workflows. Start by disabling any custom middleware or FormRequest handlers for file uploads, then use the provided Livewire components (`FilePickerModal`, `FilePickerForm`). For conflicts, wrap legacy logic in feature flags or middleware checks to route requests appropriately.
- Can I use this with a non-Livewire frontend (e.g., Vue.js or React) in a Laravel app?
- Direct integration isn’t supported, but you can expose the backend functionality via **API routes** (e.g., `FilePickerController`) and build a custom frontend wrapper. The package’s core features—storage, metadata, and deduplication—remain usable, but UI elements like drag/drop and modals would need rebuilding.
- What storage backends does this support, and how do I add custom ones (e.g., Azure Blob Storage)?
- The package defaults to Laravel’s filesystem (local, S3, etc.) but can be extended via **events/observers** or middleware. For custom backends like Azure Blob, override the `FilePickerServiceProvider` bindings or create a custom filesystem adapter that implements Laravel’s `Filesystem` contract, then bind it in the config.
- How does duplicate detection (SHA-256) work, and can I disable it for performance?
- Duplicate detection runs during upload via SHA-256 hashing, with configurable strategies (`reuse`, `reject`, or `allow`). To disable it, set `dedupe_enabled = false` in `config/file-picker.php`, but note this may increase storage costs and risk duplicates. For large files, consider caching hashes in Redis to reduce database load.
- Does this package handle multi-tenancy or shared media libraries across users?
- Yes, the package supports **user ownership** via `user_id` and can scope media per user. For multi-tenancy, extend the `FilePicker` model to include a `tenant_id` column and filter queries in middleware or model scopes. Shared libraries require custom logic to bypass user scoping.
- What happens if a user exceeds their storage quota? How can I customize quota behavior?
- Quotas are enforced during uploads, and users see a toast notification if they exceed limits. Customize quotas in `config/file-picker.php` (global/per-user) or override the `FilePickerServiceProvider` to add logic like email alerts or downgrading plans. Failed uploads return HTTP 403 with a message.
- How do I test this package in a CI/CD pipeline, especially for file uploads?
- Use Laravel’s `UploadedFile` facade in PHPUnit tests to mock file uploads. For drag/drop/paste interactions, test Livewire components with `Livewire::test()` and simulate events like `drop` or `paste`. Mock storage responses to avoid hitting real filesystems, and verify metadata (e.g., tags, folders) via database assertions.
- Are there performance concerns with large-scale uploads (e.g., 10,000+ files)?
- Heavy operations like SHA-256 hashing or thumbnail generation can slow responses. Mitigate this by **queuing async tasks** (e.g., `file-picker:generate-thumbnails`), caching hashes in Redis, and indexing the `media` table (e.g., `hash`, `user_id`). Monitor queue workers and consider batching operations like pruning.
- How do I customize the UI to match my app’s design system (e.g., Bootstrap instead of Tailwind)?
- The package uses Tailwind CSS by default, but you can override styles via the `file-picker` config’s `css` path or publish the assets (`php artisan vendor:publish --tag=file-picker-assets`). For Bootstrap, replace the provided CSS classes with Bootstrap equivalents or use a CSS preprocessor to translate Tailwind classes.