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.7] Expose readStream and writeStream to allow cross-filesystem actions #23755

Merged
merged 3 commits into from Apr 3, 2018

Conversation

Projects
None yet
3 participants
@tomlankhorst
Contributor

tomlankhorst commented Mar 30, 2018

This allows easy reading/writing of files across filesystems and to response-streams.

Across filesystems:

Storage::disk('s3')
  ->writeStream(
    'remote-file.zip',
    Storage::disk('local')->readStream('local-file.zip')
  );

To response-streams:

return response()
  ->stream( function() {
    fpassthru( Storage::disk('s3')->readStream('file.zip') );
  });

tomlankhorst added some commits Mar 30, 2018

@GrahamCampbell GrahamCampbell changed the title from Expose readStream and writeStream to allow cross-filesystem actions to [5.7] Expose readStream and writeStream to allow cross-filesystem actions Mar 30, 2018

@sisve

This comment has been minimized.

Contributor

sisve commented Mar 31, 2018

Would it make sense to have readStream throw an exception on failures instead of returning null? A null value cannot provide much debugging information into what failed.

@taylorotwell

This comment has been minimized.

Member

taylorotwell commented Apr 2, 2018

Why are we inventing new exception types. Just let Flysystem throw whatever exception it throws.

@tomlankhorst

This comment has been minimized.

Contributor

tomlankhorst commented Apr 3, 2018

@taylorotwell Such that I can specify what exceptions the implementation of the Filesystem contract might throw - analogous to FileNotFoundException - the handle them appropriately.

@tomlankhorst

This comment has been minimized.

Contributor

tomlankhorst commented Apr 3, 2018

@sisve Sure, currently this is a relic of Flysystem which returns null on failure. Could throw an exception on null return as well.

@taylorotwell taylorotwell merged commit b488c0f into laravel:master Apr 3, 2018

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment