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

Add ability to set instance of StreamInterface as output stream #172

Merged
merged 2 commits into from Nov 13, 2020
Merged

Add ability to set instance of StreamInterface as output stream #172

merged 2 commits into from Nov 13, 2020

Conversation

artemmolotov
Copy link
Contributor

@artemmolotov artemmolotov commented Nov 13, 2020

Example:

use Laminas\Diactoros\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use ZipStream\Option\Archive as ArchiveOptions;
use ZipStream\ZipStream;

...

public function example(StreamInterface $outputStream): ResponseInterface
{
    $options = new ArchiveOptions();
    $options->setOutputStream($outputStream);

    $zip = new ZipStream(null, $options);
    $zip->addFile('sample.txt', 'Sample String Data');
    $zip->finish();

    return new Response($outputStream, 200, [
        'Content-Type' => 'application/zip',
        'Content-Disposition' => 'attachment;filename="archive.zip"',
        'Cache-Control' => 'max-age=0',
    ]);
}

PSR-7's StreamInterface
ZipStream\Option\Archive::outputStream
@coveralls
Copy link

coveralls commented Nov 13, 2020

Coverage Status

Coverage increased (+1.4%) to 75.506% when pulling 384af34 on artemmolotov:feature/output-to-psr7-stream into a1882eb on maennchen:master.

NicolasCARPi
NicolasCARPi previously approved these changes Nov 13, 2020
Copy link
Sponsor Collaborator

@NicolasCARPi NicolasCARPi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maennchen maennchen merged commit 48a1637 into maennchen:master Nov 13, 2020
@artemmolotov artemmolotov deleted the feature/output-to-psr7-stream branch November 13, 2020 19:52
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.

None yet

4 participants