简体   繁体   中英

Php-opencloud Object Storage download file, GuzzleStream, how to>

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 .........

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM