This package helps you to save your images secretly and show them just to authenticated users.
You can install the package via composer:
composer require mohsenbostan/laravel-secret-image
after installing package using composer, you should publish configs:
php artisan vendor:publish --provider=Mohsenbostan\LaravelSecretImage\LaravelSecretImageServiceProvider
Custom Storage Driver
you can set a custom storage driver in config/laravel-secret-image.php
<?php
return [
/*
* Default Storage Driver To Save Images
* -------------------------------------
* Note: Don't use `public` for driver or path.
*/
'storage_driver' => env('FILESYSTEM_DRIVER', 'local'),
];
Custom Middlewares
you can set custom middlewares to protect images in config/laravel-secret-image.php
<?php
return [
/*
* Default Middlewares To Protect Images
*/
'middlewares' => [
'auth'
]
];
Save Single Secret Image
saveSingleImage
method will save image and return the image path.
use \Mohsenbostan\LaravelSecretImage\LaravelSecretImage;
$image = LaravelSecretImage::saveSingleImage(request()->file('image'));
Save Multiple Secret Images
saveMultiImages
method will save all images and return the images' path.
use \Mohsenbostan\LaravelSecretImage\LaravelSecretImage;
$images = LaravelSecretImage::saveMultiImages(request()->file('images'));
Get Secret Image Url
getImageUrl
method will return image url.
use \Mohsenbostan\LaravelSecretImage\LaravelSecretImage;
$url = LaravelSecretImage::getImageUrl($image);
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.