~ubuntu-branches/ubuntu/vivid/swift/vivid

« back to all changes in this revision

Viewing changes to doc/source/api/object_versioning.rst

  • Committer: Package Import Robot
  • Author(s): James Page, Chuck Short, James Page
  • Date: 2014-12-19 14:33:19 UTC
  • mfrom: (1.2.34)
  • Revision ID: package-import@ubuntu.com-20141219143319-kbs2wk1dixt2aoqq
Tags: 2.2.1-0ubuntu1
[ Chuck Short ]
* Open for Vivid.
* d/control: Update branch locations.

[ James Page ]
* New upstream release:
  - d/p/*: Refresh.
* d/control: Bumped Standards-Version 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=================
 
2
Object versioning
 
3
=================
 
4
 
 
5
You can store multiple versions of your content so that you can recover
 
6
from unintended overwrites. Object versioning is an easy way to
 
7
implement version control, which you can use with any type of content.
 
8
 
 
9
Note
 
10
~~~~
 
11
 
 
12
You cannot version a large-object manifest file, but the large-object
 
13
manifest file can point to versioned segments.
 
14
 
 
15
It is strongly recommended that you put non-current objects in a
 
16
different container than the container where current object versions
 
17
reside.
 
18
 
 
19
To enable object versioning, the cloud provider sets the
 
20
``allow_versions`` option to ``TRUE`` in the container configuration
 
21
file.
 
22
 
 
23
The ``X-Versions-Location`` header defines the
 
24
container that holds the non-current versions of your objects. You
 
25
must UTF-8-encode and then URL-encode the container name before you
 
26
include it in the ``X-Versions-Location`` header. This header enables
 
27
object versioning for all objects in the container. With a comparable
 
28
``archive`` container in place, changes to objects in the ``current``
 
29
container automatically create non-current versions in the ``archive``
 
30
container.
 
31
 
 
32
Here's an example:
 
33
 
 
34
#.   Create the ``current`` container:
 
35
 
 
36
   .. code::
 
37
 
 
38
       # curl -i $publicURL/current -X PUT -H "Content-Length: 0" -H "X-Auth-Token: $token" -H "X-Versions-Location: archive"
 
39
 
 
40
   .. code::
 
41
 
 
42
       HTTP/1.1 201 Created
 
43
       Content-Length: 0
 
44
       Content-Type: text/html; charset=UTF-8
 
45
       X-Trans-Id: txb91810fb717347d09eec8-0052e18997
 
46
       Date: Thu, 23 Jan 2014 21:28:55 GMT
 
47
 
 
48
#. Create the first version of an object in the ``current`` container:
 
49
 
 
50
   .. code::
 
51
 
 
52
       # curl -i $publicURL/current/my_object --data-binary 1 -X PUT -H "Content-Length: 0" -H "X-Auth-Token: $token"
 
53
 
 
54
   .. code::
 
55
 
 
56
       HTTP/1.1 201 Created
 
57
       Last-Modified: Thu, 23 Jan 2014 21:31:22 GMT
 
58
       Content-Length: 0
 
59
       Etag: d41d8cd98f00b204e9800998ecf8427e
 
60
       Content-Type: text/html; charset=UTF-8
 
61
       X-Trans-Id: tx5992d536a4bd4fec973aa-0052e18a2a
 
62
       Date: Thu, 23 Jan 2014 21:31:22 GMT
 
63
 
 
64
   Nothing is written to the non-current version container when you
 
65
   initially **PUT** an object in the ``current`` container. However,
 
66
   subsequent **PUT** requests that edit an object trigger the creation
 
67
   of a version of that object in the ``archive`` container.
 
68
 
 
69
   These non-current versions are named as follows:
 
70
 
 
71
   .. code::
 
72
 
 
73
       <length><object_name><timestamp>
 
74
 
 
75
   Where ``length`` is the 3-character, zero-padded hexadecimal
 
76
   character length of the object, ``<object_name>`` is the object name,
 
77
   and ``<timestamp>`` is the time when the object was initially created
 
78
   as a current version.
 
79
 
 
80
#. Create a second version of the object in the ``current`` container:
 
81
 
 
82
   .. code::
 
83
 
 
84
       # curl -i $publicURL/current/my_object --data-binary 2 -X PUT -H "Content-Length: 0" -H "X-Auth-Token: $token"
 
85
 
 
86
   .. code::
 
87
 
 
88
       HTTP/1.1 201 Created
 
89
       Last-Modified: Thu, 23 Jan 2014 21:41:32 GMT
 
90
       Content-Length: 0
 
91
       Etag: d41d8cd98f00b204e9800998ecf8427e
 
92
       Content-Type: text/html; charset=UTF-8
 
93
       X-Trans-Id: tx468287ce4fc94eada96ec-0052e18c8c
 
94
       Date: Thu, 23 Jan 2014 21:41:32 GMT
 
95
 
 
96
#. Issue a **GET** request to a versioned object to get the current
 
97
   version of the object. You do not have to do any request redirects or
 
98
   metadata lookups.
 
99
 
 
100
   List older versions of the object in the ``archive`` container:
 
101
 
 
102
   .. code::
 
103
 
 
104
       # curl -i $publicURL/archive?prefix=009my_object -X GET -H "X-Auth-Token: $token"
 
105
 
 
106
   .. code::
 
107
 
 
108
       HTTP/1.1 200 OK
 
109
       Content-Length: 30
 
110
       X-Container-Object-Count: 1
 
111
       Accept-Ranges: bytes
 
112
       X-Timestamp: 1390513280.79684
 
113
       X-Container-Bytes-Used: 0
 
114
       Content-Type: text/plain; charset=utf-8
 
115
       X-Trans-Id: tx9a441884997542d3a5868-0052e18d8e
 
116
       Date: Thu, 23 Jan 2014 21:45:50 GMT
 
117
 
 
118
       009my_object/1390512682.92052
 
119
 
 
120
Note
 
121
~~~~
 
122
 
 
123
   A **POST** request to a versioned object updates only the metadata
 
124
   for the object and does not create a new version of the object. New
 
125
   versions are created only when the content of the object changes.
 
126
 
 
127
#. Issue a **DELETE** request to a versioned object to remove the
 
128
   current version of the object and replace it with the next-most
 
129
   current version in the non-current container.
 
130
 
 
131
   .. code::
 
132
 
 
133
       # curl -i $publicURL/current/my_object -X DELETE -H "X-Auth-Token: $token"
 
134
 
 
135
   .. code::
 
136
 
 
137
       HTTP/1.1 204 No Content
 
138
       Content-Length: 0
 
139
       Content-Type: text/html; charset=UTF-8
 
140
       X-Trans-Id: tx006d944e02494e229b8ee-0052e18edd
 
141
       Date: Thu, 23 Jan 2014 21:51:25 GMT
 
142
 
 
143
   List objects in the ``archive`` container to show that the archived
 
144
   object was moved back to the ``current`` container:
 
145
 
 
146
   .. code::
 
147
 
 
148
       # curl -i $publicURL/archive?prefix=009my_object -X GET -H "X-Auth-Token: $token"
 
149
 
 
150
   .. code::
 
151
 
 
152
       HTTP/1.1 204 No Content
 
153
       Content-Length: 0
 
154
       X-Container-Object-Count: 0
 
155
       Accept-Ranges: bytes
 
156
       X-Timestamp: 1390513280.79684
 
157
       X-Container-Bytes-Used: 0
 
158
       Content-Type: text/html; charset=UTF-8
 
159
       X-Trans-Id: tx044f2a05f56f4997af737-0052e18eed
 
160
       Date: Thu, 23 Jan 2014 21:51:41 GMT
 
161
 
 
162
   This next-most current version carries with it any metadata last set
 
163
   on it. If want to completely remove an object and you have five
 
164
   versions of it, you must **DELETE** it five times.
 
165
 
 
166
#. To disable object versioning for the ``current`` container, remove
 
167
   its ``X-Versions-Location`` metadata header by sending an empty key
 
168
   value.
 
169
 
 
170
   .. code::
 
171
 
 
172
       # curl -i $publicURL/current -X PUT -H "Content-Length: 0" -H "X-Auth-Token: $token" -H "X-Versions-Location: "
 
173
 
 
174
   .. code::
 
175
 
 
176
       HTTP/1.1 202 Accepted
 
177
       Content-Length: 76
 
178
       Content-Type: text/html; charset=UTF-8
 
179
       X-Trans-Id: txe2476de217134549996d0-0052e19038
 
180
       Date: Thu, 23 Jan 2014 21:57:12 GMT
 
181
 
 
182
       <html><h1>Accepted</h1><p>The request is accepted for processing.</p></html>
 
183