M
M
Maxim2019-11-03 10:28:49
Laravel
Maxim, 2019-11-03 10:28:49

How to limit the rate of response->stream?

I use this option

set_time_limit(0);

        /** @var \League\Flysystem\Filesystem $fs */
        $fs = Storage::disk('files')->getDriver();

        $metaData = $fs->getMetadata($file->fullroute);
        $stream = $fs->readStream($file->fullroute);

        if (ob_get_level()) ob_end_clean();

        return response()->stream(
            function () use ($stream) {
                fpassthru($stream);
            },
            200,
            [
            'Cache-Control'         => 'private',
            'Content-Type'          => $file->type,
            'Content-Length'        => $file->size,
            'Content-Disposition'   => 'attachment; filename="' . $file->filename . '"',
            'Pragma'                => 'public',
            ]);

How can I limit upload speed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question