Method: Fog::Storage::Softlayer::Mock#put_object

Defined in:
lib/fog/softlayer/requests/storage/put_object.rb

#put_object(container, object, data, options = {}, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/softlayer/requests/storage/put_object.rb', line 5

def put_object(container, object, data, options = {}, &block)
  if @containers[container]
    @containers[container][object] = data
    response = Excon::Response.new
    response.body = ''
    response.status = 201
    response.headers = {"Last-Modified"=>Time.now, "Content-Length"=>0}
    response
  else
    response = Excon::Response.new
    response.body = '<html><h1>Not Found</h1><p>The resource could not be found.</p></html>'
    response.status = 404
    response.headers = {"Content-Length"=>"70", "Content-Type"=>"text/html; charset=UTF-8", "X-Trans-Id"=>"abcdefghijklmnopqrstuvwx-0123456789", "Date"=>Time.now}
    response
  end
end