muharihar / file-finder
Laravel Local File Finder Package
0.1.2
2018-10-14 14:53 UTC
Requires
- php: >=7.0.0
- laravel/framework: >=5.6
Requires (Dev)
- laravel/dusk: ^4.0
- phpunit/phpunit: ^7.0
This package is not auto-updated.
Last update: 2024-12-16 22:18:28 UTC
README
Laravel Local File Finder Package is a simple laravel package that allow finding a file by CONTENT (currently only for .txt file).
Online Demo:
Available Features:
- List default storage directories and files.
- Search files and directories By Name.
- Search files by Content.
REST API Features
- [Swagger UI] (http://host:port/file-finder/api/docs)
Installation
- Create Laravel Project
$ composer create-project --prefer-dist laravel/laravel laravel_file_finder_5.6_test "5.6.*"
- Add FileFinder Package
$ cd laravel_file_finder_5.6_test
$ composer require muharihar/file-finder
- Publish Assets and Default Data Samples
$ php artisan vendor:publish --tag=public --force
- Add FileFinder Service Provider to laravel application config (config/app.php)
/* * Package Service Providers... */ Muharihar\FileFinder\ServiceProviders\FileFinderServiceProvider::class,
- Running Application
$ php artisan serve
- Open Swagger UI for testing the features: http://127.0.0.1:8000/file-finder/api/docs
Test via CURL
1. List default storage directories and files.
Command:
$ curl -v -X GET "http://localhost:8000/file-finder/api/v1.0/default/list-dir-and-files" -H "accept: application/json"
Sample Result: sampleResponse
2. Search files and directories By Name.
Command:
$ curl -X GET "http://localhost:8000/file-finder/api/v1.0/search/by-name?s=b" -H "accept: application/json"
Sample Result:
{ "searchKey": "b", "results": [ { "idx": 2, "isDir": true, "shortPath": "public/file-finder/folder_animals/folder_birds", "extension": "", "fileSize": 0, "parentPath": "public/file-finder/folder_animals" }, { "idx": 12, "isDir": true, "shortPath": "public/file-finder/folder_fruits/folder_berries", "extension": "", "fileSize": 0, "parentPath": "public/file-finder/folder_fruits" }, { "idx": 13, "isDir": false, "shortPath": "public/file-finder/folder_fruits/folder_berries/file_berries_list.txt", "extension": "txt", "fileSize": 44, "parentPath": "public/file-finder/folder_fruits/folder_berries" }, { "idx": 26, "isDir": false, "shortPath": "public/file-finder/folder_geolocations/folder_cities/file_bg.txt", "extension": "txt", "fileSize": 633, "parentPath": "public/file-finder/folder_geolocations/folder_cities" } ], "resultCount": 4 }
3. Search files by Content.
Command:
$ curl -X GET "http://localhost:8000/file-finder/api/v1.0/search/by-content?s=Obama" -H "accept: application/json"
Sample Result:
{ "searchKey": "Obama", "results": [ { "idx": 41, "isDir": false, "shortPath": "public/file-finder/folder_peoples/folder_presidents/file_us.txt", "extension": "txt", "fileSize": 6713, "parentPath": "public/file-finder/folder_peoples/folder_presidents", "info": { "firstPos": 6580, "firstStr": "...Obama,http://en.wikipedia.org/wiki/Barack_Obama,20" } } ], "resultCount": 1 }