Skip to content
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

Conversation

tomlankhorst
Copy link
Contributor

@tomlankhorst 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') );
  });

@GrahamCampbell GrahamCampbell changed the title Expose readStream and writeStream to allow cross-filesystem actions [5.7] Expose readStream and writeStream to allow cross-filesystem actions Mar 30, 2018
@sisve
Copy link
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
Copy link
Member

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

@tomlankhorst
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants