简体   繁体   English

Php-opencloud对象存储下载文件,GuzzleStream,如何>

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

How do I download my object using Php-opencloud? 如何使用Php-opencloud下载我的对象? http://docs.os.php-opencloud.com/en/latest/services/object-store/v1/objects.html 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. 它返回GuzzleStream对象。 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 ......... 当我尝试回显流时,它返回乱码文本%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 $ file是我的流

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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