Skip to content

Commit 921a3dd

Browse files
author
Jamie Hannaford
committed
add docs and fix docblock
1 parent b363eb5 commit 921a3dd

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

doc/services/object-store/v1/objects.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,31 @@ returned. If you would like to access all of the remote state of a collection it
5252
If you have a large collection of $object, this will slow things down because you're issuing a HEAD request per object.
5353

5454
Create an object
55-
------------
55+
----------------
56+
57+
When creating an object, you can upload its content according to a string representation:
5658

5759
.. sample:: object_store/v1/objects/create.php
5860

61+
If that is not optimal or convenient, you can use a stream instead. Any instance of ``\Psr\Http\Message\StreamInterface``
62+
is acceptable. For example, to use a normal Guzzle stream:
63+
64+
.. sample:: object_store/v1/objects/create_from_stream.php
65+
66+
Create a large object (over 5GB)
67+
--------------------------------
68+
69+
For large objects (those over 5GB), you will need to use a concept in Swift called Dynamic Large Objects (DLO). When
70+
uploading, this is what happens under the hood:
71+
72+
1. The large file is separated into smaller segments
73+
2. Each segment is uploaded
74+
3. A manifest file is created which, when requested by clients, will concatenate all the segments as a single file
75+
76+
To upload a DLO, you need to call:
77+
78+
.. sample:: object_store/v1/objects/create_large_object.php
79+
5980
Copy object
6081
-----------
6182

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
use GuzzleHttp\Psr7\Stream;
6+
7+
$openstack = new OpenStack\OpenStack([
8+
'authUrl' => '{authUrl}',
9+
'region' => '{region}',
10+
'user' => [
11+
'id' => '{userId}',
12+
'password' => '{password}'
13+
],
14+
'scope' => ['project' => ['id' => '{projectId}']]
15+
]);
16+
17+
// You can use any instance of \Psr\Http\Message\StreamInterface
18+
$stream = new Stream(fopen('/path/to/object.txt', 'r'));
19+
20+
$options = [
21+
'name' => '{objectName}',
22+
'stream' => $stream,
23+
];
24+
25+
/** @var \OpenStack\ObjectStore\v1\Models\Object $object */
26+
$object = $openstack->objectStoreV1()
27+
->getContainer('{containerName}')
28+
->createObject($options);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
require 'vendor/autoload.php';
4+
5+
use Guzzle\Stream\Stream;
6+
7+
$openstack = new OpenStack\OpenStack([
8+
'authUrl' => '{authUrl}',
9+
'region' => '{region}',
10+
'user' => [
11+
'id' => '{userId}',
12+
'password' => '{password}'
13+
],
14+
'scope' => ['project' => ['id' => '{projectId}']]
15+
]);
16+
17+
$options = [
18+
'name' => 'object_name.txt',
19+
'stream' => new Stream(fopen('/path/to/large_object.mov', 'r')),
20+
];
21+
22+
// optional: specify the size of each segment in bytes
23+
$options['segmentSize'] = 1073741824;
24+
25+
// optional: specify the container where the segments live. This does not necessarily have to be the
26+
// same as the container which holds the manifest file
27+
$options['segmentContainer'] = 'test_segments';
28+
29+
30+
/** @var \OpenStack\ObjectStore\v1\Models\Object $object */
31+
$object = $openstack->objectStoreV1()
32+
->getContainer('test')
33+
->createLargeObject($options);

src/Networking/v2/Service.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function listSubnets(array $options = [])
117117
/**
118118
* Create a new port resource.
119119
*
120-
* @param array $options {@see \OpenStack\Networking\v2\Api::postPort}
120+
* @param array $options {@see \OpenStack\Networking\v2\Api::postPorts}
121121
*
122122
* @return Port
123123
*/

0 commit comments

Comments
 (0)