All Projects → armancodes → Laravel Download Link

armancodes / Laravel Download Link

Licence: mit
A simple Laravel package for generating download links with options such as expire time, IP restrictions, etc.

Labels

Projects that are alternatives of or similar to Laravel Download Link

Shopper
An eCommerce administration built with Laravel 5 for create online shop.
Stars: ✭ 205 (-4.65%)
Mutual labels:  laravel
Laravel Echo Server
Socket.io server for Laravel Echo
Stars: ✭ 2,487 (+1056.74%)
Mutual labels:  laravel
Laravel Custom Casts
Make your own custom cast type for Laravel model attributes
Stars: ✭ 213 (-0.93%)
Mutual labels:  laravel
Invoiceneko
An Open Sourced Invoice System developed for anyone who needs to generate out an invoice and manage clients
Stars: ✭ 204 (-5.12%)
Mutual labels:  laravel
Meter
Laravel package to find performance bottlenecks in your laravel application.
Stars: ✭ 204 (-5.12%)
Mutual labels:  laravel
Laravel Jit Loader
Stars: ✭ 210 (-2.33%)
Mutual labels:  laravel
Laravel Executor
Configurable code that can be run when installing and updating your web app.
Stars: ✭ 204 (-5.12%)
Mutual labels:  laravel
Speedtest Tracker
Continuously track your internet speed
Stars: ✭ 209 (-2.79%)
Mutual labels:  laravel
Workflow
基于laravel的工作流项目
Stars: ✭ 209 (-2.79%)
Mutual labels:  laravel
Nova Button
Add buttons on Nova index, detail and lens views.
Stars: ✭ 213 (-0.93%)
Mutual labels:  laravel
Lighthouse
A framework for serving GraphQL from Laravel
Stars: ✭ 2,685 (+1148.84%)
Mutual labels:  laravel
Laravel Partialcache
Blade directive to cache rendered partials in laravel
Stars: ✭ 205 (-4.65%)
Mutual labels:  laravel
Blog
Hi, I am CrazyCodes, and here are all my articles
Stars: ✭ 212 (-1.4%)
Mutual labels:  laravel
Nova Tags Field
A tags field to use in your Nova apps
Stars: ✭ 204 (-5.12%)
Mutual labels:  laravel
Laravel State Machine
Winzou State Machine service provider for Laravel
Stars: ✭ 213 (-0.93%)
Mutual labels:  laravel
Search Engine Rank
🐘根据网站关键词,获取网站在各大搜索引擎(百度、360、搜狗)的排名情况,有利于网站seo
Stars: ✭ 197 (-8.37%)
Mutual labels:  laravel
Panel
Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
Stars: ✭ 2,988 (+1289.77%)
Mutual labels:  laravel
Laravel Multisite
Multiple sites on one codebase
Stars: ✭ 214 (-0.47%)
Mutual labels:  laravel
Laravel Pagseguro
Checkout Transparente e Pagamentos Recorrentes (Assinaturas)
Stars: ✭ 213 (-0.93%)
Mutual labels:  laravel
Materialize Blog
redesign blog using material design
Stars: ✭ 212 (-1.4%)
Mutual labels:  laravel

Generate download links in your Laravel applications

Latest Version on Packagist Scrutinizer Code Quality GitHub Tests Action Status Total Downloads

This package allows you to generate download links for files.

Once installed you can do stuff like this:

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->generate();
// zkTu70fieUFZLGMoEP95l1RQfFj5zCOqHlM0XBTnc6ZaZTtm4GY5xPXGGLzLEAVe

The default download route in the config file is "download", so if your domain is "example.com", then you should use this link:

example.com/download/{link}

// For example
example.com/download/zkTu70fieUFZLGMoEP95l1RQfFj5zCOqHlM0XBTnc6ZaZTtm4GY5xPXGGLzLEAVe

Note: You should replace {link} with the generated link.

Installation

You can install the package via composer:

composer require armancodes/laravel-download-link

You can publish and run the migrations with:

php artisan vendor:publish --provider="Armancodes\DownloadLink\DownloadLinkServiceProvider" --tag="migrations"

php artisan migrate

You can publish the config file with:

php artisan vendor:publish --provider="Armancodes\DownloadLink\DownloadLinkServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /*
    |--------------------------------------------------------------------------
    | Download Route
    |--------------------------------------------------------------------------
    |
    | Download route will be added to your app URL for using download links.
    | E.g. if your app URL is "example.com", then if your set the download route to
    | "download" it will be "example.com/download/{link}".
    |
    */
    'download_route' => 'download',
];

Usage

You can explicitly set the file name to be saved and downloaded with the given name:

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->fileName('new-text.txt')->generate();

Expire time can also be added, so that the link will only be available before it expires:

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->expire(now()->addDay())->generate();

You can also specify if only authenticated users or guests should be able to use the link:

// Authenticated users only
$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->auth()->generate();

// Guests only
$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->guest()->generate();

You may put one or more ip addresses into a blacklist (Download links won't work with those ip addresses):

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->limitIp('127.0.0.1')->generate();

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->limitIp(['127.0.0.1', '127.0.0.2', '127.0.0.3'])->generate();

Or you may put one or more ip addresses into whitelist (Download links will ONLY work with those ip addresses):

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->allowIp('127.0.0.1')->generate();

$link = DownloadLink::disk('public')->filePath('uploads/test.txt')->allowIp(['127.0.0.1', '127.0.0.2', '127.0.0.3'])->generate();

The default download route in the config file is "download", so if your domain is "example.com", then you should use this link to download:

example.com/download/{link}

// For example
example.com/download/zkTu70fieUFZLGMoEP95l1RQfFj5zCOqHlM0XBTnc6ZaZTtm4GY5xPXGGLzLEAVe

Note: You should replace {link} with the generated link.

You can delete a link like this:

DownloadLink::delete('link');

// For example
DownloadLink::delete('zkTu70fieUFZLGMoEP95l1RQfFj5zCOqHlM0XBTnc6ZaZTtm4GY5xPXGGLzLEAVe');

You may delete the expired links in the database using the command below:

php artisan download-links:remove-expired

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].