Download the PHP package abianbiya/filehandler without Composer
On this page you can find all versions of the php package abianbiya/filehandler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abianbiya/filehandler
More information about abianbiya/filehandler
Files in abianbiya/filehandler
Package filehandler
Short Description Filehandler for storing and versioning files in Laravel
License MIT
Homepage https://github.com/abianbiya/filehandler
Informations about the package filehandler
Abianbiya/Filehandler
Simple package for handling upload file and versioning to local disk or AWS S3.
Installation
Via Composer
Usage
Main todo
- Make your model (that gonna have attached file into it) implements
HasFile
and useInteractsWithFile
trait - That's it.
Configure the default disk
- Set
FILESYSTEM_DISK
env variable (local or s3) - Fill the configuration detail if you use s3
Storing file
Storing uploaded file from request
- Set your request validation
-
Catch the file field by calling the model and then save it
- fieldname is the form
name
- foldername is.. you know, the kind of file or whatever that categories the file into some sh*t (actually this will be used as the folder name in the storage)
- fieldname is the form
Storing file from path
- path is the path
- foldername is.. you know, the
kind
of file or whatever that categories the file into some sh*t (actually this will be used as the folder name in the storage)
Setting file properties
Set some properties to the model's attached file with this function right before ->addFileFrom{What}
called.
disk()
for specifying the disk, default disk is env FILESYSTEM_DISKsetProperties()
for additional information, put array here, this'll be store as jsonreplace()
if the model has only one file stored to specified folder, then on update we can call this
Retrieving the file
Access the file with adding the file
or files
eager loading ORM relation to you model. file
function stands for the single attached file and files
for multiple files.
this relation return MediaFile object instance so you can filter it using collection for multiple files or do some operation such as:
- Publish asset to use lightbox within getThumbnail() method
then load the assets
additional option for wrapping file upload form with drag-and-drop input
then use class .dropify
Intercepting File Access (using masked URL)
The default access to the file is true
, otherwise you would like to add a gate to the masked URL route, add this method into your implemented InteractsWithFile model:
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please poke me at @abianbiya (wherever) instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
All versions of filehandler with dependencies
laravel/framework Version ^9.0|^10.0|^11.0|^12.0
league/flysystem-aws-s3-v3 Version ^3.0