1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[storage|rackspace] add large object support via put_object_manifest

closes #228
This commit is contained in:
geemus 2011-06-24 16:00:44 -07:00
parent 74da1fe16e
commit 07f788cf64
5 changed files with 74 additions and 5 deletions

View file

@ -22,6 +22,7 @@ module Fog
request :head_object
request :put_container
request :put_object
request :put_object_manifest
module Utils

View file

@ -7,6 +7,9 @@ module Fog
#
# ==== Parameters
# * container<~String> - Name for container, should be < 256 bytes and must not contain '/'
# * object<~String> - Name for object
# * data<~String|File> - data to upload
# * options<~Hash> - config headers for object. Defaults to {}.
#
def put_object(container, object, data, options = {})
data = Fog::Storage.parse_data(data)

View file

@ -0,0 +1,25 @@
module Fog
module Storage
class Rackspace
class Real
# Create a new object
#
# ==== Parameters
# * container<~String> - Name for container, should be < 256 bytes and must not contain '/'
# * object<~String> - Name for object
#
def put_object_manifest(container, object)
path = "#{URI.escape(container)}/#{URI.escape(object)}"
request(
:expects => 201,
:headers => {'X-Object-Manifest' => path},
:method => 'PUT',
:path => path
)
end
end
end
end
end

View file

@ -1,4 +1,4 @@
Shindo.tests('Fog::Storage[:aws] | object requests', [:aws]) do
Shindo.tests('Fog::Storage[:aws] | multipart upload requests', [:aws]) do
@directory = Fog::Storage[:aws].directories.create(:key => 'fogmultipartuploadtests')
@ -98,10 +98,7 @@ Shindo.tests('Fog::Storage[:aws] | object requests', [:aws]) do
tests("#get_object('#{@directory.identity}', 'fog_multipart_upload').body").succeeds do
pending if Fog.mocking?
data = Fog::Storage[:aws].get_object(@directory.identity, 'fog_multipart_upload').body
unless data == ('x' * 10 * 1024 * 1024)
raise 'content mismatch'
end
Fog::Storage[:aws].get_object(@directory.identity, 'fog_multipart_upload').body == ('x' * 10 * 1024 * 1024)
end
if !Fog.mocking?

View file

@ -0,0 +1,43 @@
Shindo.tests('Fog::Storage[:rackspace] | large object requests', [:rackspace]) do
@directory = Fog::Storage[:rackspace].directories.create(:key => 'foglargeobjecttests')
tests('success') do
tests("#put_object('#{@directory.identity}', 'fog_large_object/1', ('x' * 6 * 1024 * 1024))").succeeds do
pending if Fog.mocking?
Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/1', ('x' * 6 * 1024 * 1024))
end
tests("#put_object('#{@directory.identity}', 'fog_large_object/2', ('x' * 4 * 1024 * 1024))").succeeds do
pending if Fog.mocking?
Fog::Storage[:rackspace].put_object(@directory.identity, 'fog_large_object/2', ('x' * 4 * 1024 * 1024))
end
tests("#put_object_manifest('#{@directory.identity}', 'fog_large_object')").succeeds do
pending if Fog.mocking?
Fog::Storage[:rackspace].put_object_manifest(@directory.identity, 'fog_large_object')
end
tests("#get_object('#{@directory.identity}', 'fog_large_object').body").succeeds do
pending if Fog.mocking?
Fog::Storage[:rackspace].get_object(@directory.identity, 'fog_large_object').body == ('x' * 10 * 1024 * 1024)
end
if !Fog.mocking?
['fog_large_object', 'fog_large_object/1', 'fog_large_object/2'].each do |key|
@directory.files.new(:key => key).destroy
end
end
end
tests('failure') do
tests("put_object_manifest")
end
@directory.destroy
end