1

How do I download my object using Php-opencloud? http://docs.os.php-opencloud.com/en/latest/services/object-store/v1/objects.html

In the documentation I see.

$stream = $openstack->objectStoreV1()
                ->getContainer('{containerName}')
                ->getObject('{objectName}')
                ->download();

It return GuzzleStream Object. How do I popup a screen for prompting file download?

When I Try to echo the stream, it returns garbled text %PDF-1.4 %�쏢 5 0 obj .........

Sen
  • 308
  • 2
  • 13

1 Answers1

1

I just add a header and flush the buffer

header('Content-Disposition: attachment; filename=' . basename($request));
    header("Content-Type: ".$mime);
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . $file->getSize());
    ob_clean();
    flush();

    echo $file;

$file is my stream

Sen
  • 308
  • 2
  • 13