mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack|storage] add #put_dynamic_obj_manifest
Renames the current #put_object_manifest method to better differentiate this from the new #put_static_obj_manifest method. #put_object_manifest has been retained for backward compatibility.
This commit is contained in:
parent
d3ac285625
commit
56c28d2cb2
4 changed files with 59 additions and 33 deletions
|
@ -0,0 +1,43 @@
|
||||||
|
module Fog
|
||||||
|
module Storage
|
||||||
|
class OpenStack
|
||||||
|
class Real
|
||||||
|
|
||||||
|
# Create a new dynamic large object manifest
|
||||||
|
#
|
||||||
|
# Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("<container>/<prefix>")
|
||||||
|
# for all uploaded segments. Retrieving the manifest object streams all segments matching this prefix.
|
||||||
|
# Segments must sort in the order they should be concatenated. Note that any future objects stored in the container
|
||||||
|
# along with the segments that match the prefix will be included when retrieving the manifest object.
|
||||||
|
#
|
||||||
|
# All segments must be stored in the same container, but may be in a different container than the manifest object.
|
||||||
|
# The default +X-Object-Manifest+ header is set to "+container+/+object+", but may be overridden in +options+
|
||||||
|
# to specify the prefix and/or the container where segments were stored.
|
||||||
|
# If overridden, names should be CGI escaped (excluding spaces) if needed (see {Fog::OpenStack.escape}).
|
||||||
|
#
|
||||||
|
# @param container [String] Name for container where +object+ will be stored. Should be < 256 bytes and must not contain '/'
|
||||||
|
# @param object [String] Name for manifest object.
|
||||||
|
# @param options [Hash] Config headers for +object+.
|
||||||
|
# @option options [String] 'X-Object-Manifest' ("container/object") "<container>/<prefix>" for segment objects.
|
||||||
|
#
|
||||||
|
# @raise [Fog::Storage::OpenStack::NotFound] HTTP 404
|
||||||
|
# @raise [Excon::Errors::BadRequest] HTTP 400
|
||||||
|
# @raise [Excon::Errors::Unauthorized] HTTP 401
|
||||||
|
# @raise [Excon::Errors::HTTPStatusError]
|
||||||
|
#
|
||||||
|
# @see http://docs.openstack.org/api/openstack-object-storage/1.0/content/dynamic-large-object-creation.html
|
||||||
|
def put_dynamic_obj_manifest(container, object, options = {})
|
||||||
|
path = "#{Fog::OpenStack.escape(container)}/#{Fog::OpenStack.escape(object)}"
|
||||||
|
headers = {'X-Object-Manifest' => path}.merge(options)
|
||||||
|
request(
|
||||||
|
:expects => 201,
|
||||||
|
:headers => headers,
|
||||||
|
:method => 'PUT',
|
||||||
|
:path => path
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,33 +3,11 @@ module Fog
|
||||||
class OpenStack
|
class OpenStack
|
||||||
class Real
|
class Real
|
||||||
|
|
||||||
# Create a new manifest object
|
# Create a new dynamic large object manifest
|
||||||
#
|
#
|
||||||
# Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("<container>/<prefix>")
|
# This is an alias for {#put_dynamic_obj_manifest} for backward compatibility.
|
||||||
# for all uploaded segments. Retrieving the manifest object streams all segments matching this prefix.
|
|
||||||
# Segments must sort in the order they should be concatenated. Note that any future objects stored in the container
|
|
||||||
# along with the segments that match the prefix will be included when retrieving the manifest object.
|
|
||||||
#
|
|
||||||
# All segments must be stored in the same container, but may be in a different container than the manifest object.
|
|
||||||
# The default +X-Object-Manifest+ header is set to "+container+/+object+", but may be overridden in +options+
|
|
||||||
# to specify the prefix and/or the container where segments were stored.
|
|
||||||
# If overridden, names should be CGI escaped (excluding spaces) if needed (see {Fog::Rackspace.escape}).
|
|
||||||
#
|
|
||||||
# @param container [String] Name for container where +object+ will be stored. Should be < 256 bytes and must not contain '/'
|
|
||||||
# @param object [String] Name for manifest object.
|
|
||||||
# @param options [Hash] Config headers for +object+.
|
|
||||||
# @option options [String] 'X-Object-Manifest' ("container/object") "<container>/<prefix>" for segment objects.
|
|
||||||
#
|
|
||||||
# @see http://docs.openstack.org/api/openstack-object-storage/1.0/content/large-object-creation.html
|
|
||||||
def put_object_manifest(container, object, options = {})
|
def put_object_manifest(container, object, options = {})
|
||||||
path = "#{Fog::OpenStack.escape(container)}/#{Fog::OpenStack.escape(object)}"
|
put_dynamic_obj_manifest(container, object, options)
|
||||||
headers = {'X-Object-Manifest' => path}.merge(options)
|
|
||||||
request(
|
|
||||||
:expects => 201,
|
|
||||||
:headers => headers,
|
|
||||||
:method => 'PUT',
|
|
||||||
:path => path
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,7 @@ module Fog
|
||||||
request :put_container
|
request :put_container
|
||||||
request :put_object
|
request :put_object
|
||||||
request :put_object_manifest
|
request :put_object_manifest
|
||||||
|
request :put_dynamic_obj_manifest
|
||||||
request :put_static_obj_manifest
|
request :put_static_obj_manifest
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
|
@ -48,10 +48,14 @@ Shindo.tests('Fog::Storage[:openstack] | large object requests', ['openstack'])
|
||||||
tests('dynamic large object requests') do
|
tests('dynamic large object requests') do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
tests('#put_object_manifest alias').succeeds do
|
||||||
|
Fog::Storage[:openstack].put_object_manifest(@directory.identity, 'fog_large_object')
|
||||||
|
end
|
||||||
|
|
||||||
tests('using default X-Object-Manifest header') do
|
tests('using default X-Object-Manifest header') do
|
||||||
|
|
||||||
tests('#put_object_manifest').succeeds do
|
tests('#put_dynamic_obj_manifest').succeeds do
|
||||||
Fog::Storage[:openstack].put_object_manifest(@directory.identity, 'fog_large_object')
|
Fog::Storage[:openstack].put_dynamic_obj_manifest(@directory.identity, 'fog_large_object')
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('#get_object streams all segments matching the default prefix').succeeds do
|
tests('#get_object streams all segments matching the default prefix').succeeds do
|
||||||
|
@ -71,9 +75,9 @@ Shindo.tests('Fog::Storage[:openstack] | large object requests', ['openstack'])
|
||||||
|
|
||||||
tests('specifying X-Object-Manifest segment prefix') do
|
tests('specifying X-Object-Manifest segment prefix') do
|
||||||
|
|
||||||
tests('#put_object_manifest').succeeds do
|
tests('#put_dynamic_obj_manifest').succeeds do
|
||||||
options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
|
options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
|
||||||
Fog::Storage[:openstack].put_object_manifest(@directory.identity, 'fog_large_object', options)
|
Fog::Storage[:openstack].put_dynamic_obj_manifest(@directory.identity, 'fog_large_object', options)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('#get_object streams segments only matching the specified prefix').succeeds do
|
tests('#get_object streams segments only matching the specified prefix').succeeds do
|
||||||
|
@ -91,9 +95,9 @@ Shindo.tests('Fog::Storage[:openstack] | large object requests', ['openstack'])
|
||||||
|
|
||||||
tests('storing manifest in a different container than the segments') do
|
tests('storing manifest in a different container than the segments') do
|
||||||
|
|
||||||
tests('#put_object_manifest').succeeds do
|
tests('#put_dynamic_obj_manifest').succeeds do
|
||||||
options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
|
options = { 'X-Object-Manifest' => "#{ @directory.identity }/fog_large_object/" }
|
||||||
Fog::Storage[:openstack].put_object_manifest(@directory2.identity, 'fog_large_object', options)
|
Fog::Storage[:openstack].put_dynamic_obj_manifest(@directory2.identity, 'fog_large_object', options)
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('#get_object').succeeds do
|
tests('#get_object').succeeds do
|
||||||
|
@ -207,8 +211,8 @@ Shindo.tests('Fog::Storage[:openstack] | large object requests', ['openstack'])
|
||||||
tests('dynamic large object requests') do
|
tests('dynamic large object requests') do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
|
|
||||||
tests('#put_object_manifest with missing container').raises(Fog::Storage::OpenStack::NotFound) do
|
tests('#put_dynamic_obj_manifest with missing container').raises(Fog::Storage::OpenStack::NotFound) do
|
||||||
Fog::Storage[:openstack].put_object_manifest('fognoncontainer', 'fog_large_object')
|
Fog::Storage[:openstack].put_dynamic_obj_manifest('fognoncontainer', 'fog_large_object')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue