jeudi 11 février 2016

In Laravel 5.1 when I send header Content-type to download a file, do I have to put die() at the end?

This is my helper

function fileDownload(EloquentFile $file, bool $stream): bool {

    $file_dir = $file->dir . '/';
    $file_url = $file_dir . $file->id;

    $stream = $stream === true ? 'attachment' : 'inline';

    if (Storage::disk('s3')->has($file_url)) {
        header('Content-type: ' . $file->mime);
        header('Content-Disposition: ' . $stream . '; filename=' . $file->name);
        header('Content-Length: ' . $file->size);
        echo Storage::disk('s3')->get($file_url);

        //die(); do I have to put die here?
    }

    abort(404);
}

Question - does commented die() is required here or can I skip it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire