2016-07-01 1 views
1

Php-opencloud를 사용하여 개체를 다운로드하려면 어떻게해야합니까? http://docs.os.php-opencloud.com/en/latest/services/object-store/v1/objects.htmlphp-opencloud 개체 저장소 다운로드 파일, GuzzleStream, 방법>

내가 본 문서에서.

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

GuzzleStream 개체를 반환합니다. 파일 다운로드를 요청하는 화면을 어떻게 표시합니까? 내가 스트림 에코하려고 할 때

, 그것은 잘못된 텍스트를 %PDF-1.4 %�쏢 5 0 obj .........

난 그냥 버퍼를 헤더를 추가하고 플러시

답변

0

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; 

$ 파일이 내 스트림

을 반환