Skip to content

Download large files #19

@ammannbe

Description

@ammannbe

When I try to download large files (50MB or greater) I get following error:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 765055744 bytes) {"userId":14,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Allowed memory size of 134217728 bytes exhausted (tried to allocate 765055744 bytes) at /my-project/vendor/monicahq/laravel-sabre/src/Sabre/Server.php:87)
[stacktrace]
#0 /my-project/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(148): Symfony\\Component\\Debug\\Exception\\FatalErrorException->__construct()
#1 /my-project/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(134): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->fatalExceptionFromError()
#2 /my-project/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(0): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleShutdown()
#3 /my-project/vendor/monicahq/laravel-sabre/src/Sabre/Server.php(87): stream_get_contents()
#4 /my-project/vendor/symfony/http-foundation/StreamedResponse.php(114): LaravelSabre\\Sabre\\Server->LaravelSabre\\Sabre\\{closure:/my-project/vendor/monicahq/laravel-sabre/src/Sabre/Server.php:85-91}()
#5 /my-project/vendor/symfony/http-foundation/Response.php(376): Symfony\\Component\\HttpFoundation\\StreamedResponse->sendContent()
#6 /my-project/public/index.php(58): Symfony\\Component\\HttpFoundation\\StreamedResponse->send()
#7 /my-project/server.php(21): ()
#8 /my-project/server.php(0): {main}()
#9 {main}
"}

If I replace the lines vendor/monicahq/laravel-sabre/src/Sabre/Server.php:85-91 to:

if (ob_get_level()) ob_end_clean();
return response()->stream(function () use ($body) {
    fpassthru($body);
}, $status, $headers);

it works perfectly.

So my qustions are:

  • Is it possible to change the response as I did or does this break functionality?
  • Isn't it possible to fully delegate Sabre/DAV the responses?

Note: I want to support files up to 10GB, so just to increase the memory_limit, I think, isn't a good idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions