2

In Laravel, I can download using

response()->download();

But is there any way to limit client speed?

amin saffar
  • 1,614
  • 3
  • 16
  • 29
Batman
  • 21
  • 1

2 Answers2

1

You can use this package:

https://github.com/bandwidth-throttle/bandwidth-throttle

Installation

composer require bandwidth-throttle/bandwidth-throttle

This example will stream a video with a rate of 100KiB/s to the browser:

use bandwidthThrottle\BandwidthThrottle;

$in  = fopen(__DIR__ . "/video.mpg", "r");
$out = fopen("php://output", "w");

$throttle = new BandwidthThrottle();
$throttle->setRate(100, BandwidthThrottle::KIBIBYTES); // Set limit to 100KiB/s
$throttle->throttle($out);

stream_copy_to_stream($in, $out);
amin saffar
  • 1,614
  • 3
  • 16
  • 29
0

No as far as i know, you can't limit the download speed via script.

Riaz Laskar
  • 1,241
  • 9
  • 15