File tree Expand file tree Collapse file tree
samples/objectstore/v1/objects
tests/integration/ObjectStore/v1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require 'vendor/autoload.php ' ;
4+
5+ $ openstack = new OpenStack \OpenStack ([
6+ 'authUrl ' => '{authUrl} ' ,
7+ 'region ' => '{region} ' ,
8+ 'user ' => [
9+ 'id ' => '{userId} ' ,
10+ 'password ' => '{password} '
11+ ],
12+ 'scope ' => ['project ' => ['id ' => '{projectId} ' ]]
13+ ]);
14+
15+ /** @var \GuzzleHttp\Stream\Stream $stream */
16+ $ stream = $ openstack ->objectStoreV1 ()
17+ ->getContainer ('{containerName} ' )
18+ ->getObject ('{objectName} ' )
19+ ->download (['requestOptions ' => ['stream ' => true ]]);
Original file line number Diff line number Diff line change @@ -153,6 +153,17 @@ public function objects()
153153 $ this ->assertInstanceOf (StreamInterface::class, $ stream );
154154 $ this ->assertEquals (1000 , $ stream ->getSize ());
155155
156+ $ this ->logStep ('Downloading object using streaming ' );
157+ /** @var StreamInterface $stream */
158+ require_once $ this ->sampleFile ($ replacements , 'objects/download_stream.php ' );
159+ $ this ->assertInstanceOf (StreamInterface::class, $ stream );
160+
161+ $ body = '' ;
162+ while (!$ stream ->eof ()) {
163+ $ body .= $ stream ->read (64 );
164+ }
165+ $ this ->assertEquals (1000 , strlen ($ body ));
166+
156167 $ this ->logStep ('Get object ' );
157168 require_once $ this ->sampleFile ($ replacements , 'objects/get.php ' );
158169
You can’t perform that action at this time.
0 commit comments