Method: Dag::Object#write

Defined in:
lib/dag/client/model/object.rb

#write(data, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/dag/client/model/object.rb', line 30

def write(data, options = {})
  if data.is_a?(String)
    data = StringIO.new(data)
  elsif data.is_a?(Pathname)
    data = File.open(data, 'rb')
  elsif data.respond_to?(:read) && data.respond_to?(:eof?)
  end

  unless options[:multipart]
    @api.create_object(@bucket, @name, options) do
      data
    end
  else
    @api.create_multipart_object(@bucket, @name, options) do
      data
    end
  end
  data.close

  nil
end