File tree Expand file tree Collapse file tree 4 files changed +84
-2
lines changed
doc/services/object-store/v1
samples/object_store/v1/objects Expand file tree Collapse file tree 4 files changed +84
-2
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,31 @@ returned. If you would like to access all of the remote state of a collection it
52
52
If you have a large collection of $object, this will slow things down because you're issuing a HEAD request per object.
53
53
54
54
Create an object
55
- ------------
55
+ ----------------
56
+
57
+ When creating an object, you can upload its content according to a string representation:
56
58
57
59
.. sample :: object_store/v1/objects/create.php
58
60
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
+
59
80
Copy object
60
81
-----------
61
82
Original file line number Diff line number Diff line change
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 );
Original file line number Diff line number Diff line change
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 );
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ public function listSubnets(array $options = [])
117
117
/**
118
118
* Create a new port resource.
119
119
*
120
- * @param array $options {@see \OpenStack\Networking\v2\Api::postPort }
120
+ * @param array $options {@see \OpenStack\Networking\v2\Api::postPorts }
121
121
*
122
122
* @return Port
123
123
*/
You can’t perform that action at this time.
0 commit comments