codegor / laravel-file-process
Laravel file receive with base64 encode, store it and generate file url. Than you can get the file with the url
Requires
- php: >=7.1
- ext-openssl: *
- ext-zlib: *
- laravel/framework: *
README
A laravel plugin for receive base64 file, store and generate url. Then get the file from the url.
How to install?
-
Install File API
composer require codegor/laravel-file-process
-
publish config file
php artisan vendor:publish --provider="Codegor\Upload\Providers\UploadServiceProvider" --tag=config
How to config?
in config/upload.php
-
fill in the extansion of acepted files.
'extantion' => 'jpeg,jpg,png,bmp,svg,gif,pdf,doc,docx,xls,xlsx',
-
fill in the secret for url encode (.env or config/upload.php).
.env
UPLOAD_SECRET=TZi+PA3dT8BR7yproQcqUryieefUbp3iedGQXCMvcSA= UPLOAD_VI=+dOnDRg9kO8arkWlsLDyMQ==
You can regenerate it paste to PHP Tester this code:
<?php echo 'UPLOAD_SECRET='.base64_encode(openssl_random_pseudo_bytes(32)); echo PHP_EOL; echo 'UPLOAD_VI='.base64_encode(openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC')));
-
fill in the route group for grop of route file - (def route path is '/file/{hash}')
'route_group' => [... your group route config],
How to use?
For save file from a client (file in base64 encoding) do this:
$url = \Codegor\Upload\Store::uploadFileRndName($extentionOfFile, $base64DataOfFile); // $url = '/file/xozYGselci9i70cTdmpvWkrYvGN9AmA7djc5eOcFoAM='
If you try to view from the browser the $url you will see it, becouse route and contoller present on this library.
Store path: {storege}/app/file/{user_id}[/0..xx?]/{hash}.{ext}
More informayion you can see at code (folder src)