mohsenbostan/laravel-secret-image

A package to save images secretly.

v1.2.1 2020-09-09 06:58 UTC

This package is auto-updated.

Last update: 2024-11-11 02:15:42 UTC


README

Latest Version on Packagist Total Downloads Build Status

This package helps you to save your images secretly and show them just to authenticated users.

Installation

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

Usage

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);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mohsenbostandev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.