Download the PHP package unisharp/laravel-fileapi without Composer
On this page you can find all versions of the php package unisharp/laravel-fileapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-fileapi
Laravel File API
Features
- Handle files with Laravel Storage.
- Load files through Laravel routing instead of public path.
- Save images with thumbs, compressed image, and sizes are customisable.
Installation
-
Install File API
-
Set service provider in
config/app.php
- publish config file
Config
in config/fileapi.php
-
fill in the storage path, which make routes for you.
it will generate routes like below :
-
set default thumb sizes(by key and value)
-
set default image compress quality
-
choose whether you want to enable upload directly by url(api)
and upload to url by below
- and you might also want to set some middlewares to protect the upload route
Usage
Initialize File API
Save By Giving Uploaded File
-
Default Usage : get unique filename
-
Custimize your upload file name
- By default will set three thumbs(equal scaling)
Thumbnail functions
-
Set custom thumb sizes
- make cropped thumbs
Get image url
Delete image and thumbs
Get file fullpath (abstract path from Laravel Storage)
Parse File Path to URL
if you store your file into cloud storage and you want to get url cloud site, you can use url() method to get it
Work with Laravel Storage
-
Get file content
-
Write files
- Get Mime Type
Auto Upload
if enable_api_upload=true
in config/fileapi.php
, you can upload file to these two path
-
Image
-
head
POST /api/v1/images/{target}/{param?}
-
body
image={file multipart body}
-
-
Video
-
head
/api/v1/videos/{target}/{param?}
-
body
video={file multipar body}
-
After uploaded
you add event listener to finish up after file uploaded, file api will fire image.{target}.created
and
video.{target}.created
Step
-
Write listener under
App\Listeners
<?php namespace App\Listeners; class ArticleImageListener { public function handle($param, $filename, $path) { ... do something ... } }
-
Write event mapping in
Providers\EvnetService\Providers
protected $listen = [ 'image.article.created' => [ 'App\Listeners\ArticleImageListener' ], ];
Configurations
'enable_api_upload' => false, // auto upload api
'api_prefix' => '/api/v1', // upload api url prefix
'middlewares' => [], // middlewares that wrap the api upload route
All versions of laravel-fileapi with dependencies
illuminate/support Version >=5.0.0
league/flysystem Version >=1.0
symfony/http-foundation Version >=2.0
ext-gd Version *