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

1.3.0 2020-10-22 17:11 UTC

This package is auto-updated.

Last update: 2024-11-23 02:16:56 UTC


README

A laravel plugin for receive base64 file, store and generate url. Then get the file from the url.

How to install?

  1. Install File API

    composer require codegor/laravel-file-process
  2. publish config file

    php artisan vendor:publish --provider="Codegor\Upload\Providers\UploadServiceProvider" --tag=config

How to config?

in config/upload.php

  1. fill in the extansion of acepted files.

    'extantion' => 'jpeg,jpg,png,bmp,svg,gif,pdf,doc,docx,xls,xlsx',
  2. 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')));
  3. 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)