New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Add response and download methods to file system #22089

Merged
merged 2 commits into from Nov 16, 2017

Conversation

Projects
None yet
3 participants
@reinink
Contributor

reinink commented Nov 16, 2017

These are helpful in situations where you want to return a file from storage as a response. For example:

class DocumentController extends Controller
{
    public function show(Document $document)
    {
        // Return the document as a response
        return Storage::response($document->path);

        // Use a custom filename
        return Storage::response($document->path, 'sweet.pdf');

        // Force the file to download
        return Storage::download($document->path);
    }
}

These return a StreamedResponse, allowing the file contents to begin outputting to the browser while still downloading from their source. This is especially useful for cloud file systems like S3 or Rackspace.

The download method is really just a shortcut for the response method with the $disposition set to attachment.

reinink added some commits Nov 16, 2017

Add response and download methods to file system
These are helpful in situations where you want to return a file from storage as a response. These return a `StreamedResponse`, allowing the file contents to begin outputting to the browser while still downloading from their source. This is especially useful for cloud file systems like S3 or Rackspace.

The download method is really just a shortcut for the response method with the "disposition" value set to "attachment".

@taylorotwell taylorotwell merged commit 0957bb5 into laravel:5.5 Nov 16, 2017

2 checks passed

continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ninjaparade

This comment has been minimized.

Show comment
Hide comment
@ninjaparade

ninjaparade Nov 16, 2017

Contributor

@reinink not bad for a CSS guy.

Please rate

Contributor

ninjaparade commented Nov 16, 2017

@reinink not bad for a CSS guy.

Please rate

@GrahamCampbell GrahamCampbell changed the title from Add response and download methods to file system to [5.5] Add response and download methods to file system Nov 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment