Method: FakeS3::FileStore#do_store_object

Defined in:
lib/fakes3/file_store.rb

#do_store_object(bucket, object_name, filedata, request) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/fakes3/file_store.rb', line 191

def do_store_object(bucket, object_name, filedata, request)
  begin
    filename = File.join(@root, bucket.name, object_name)
    FileUtils.mkdir_p(filename)

     = File.join(filename, )
    FileUtils.mkdir_p()

    content = File.join(filename, , "content")
     = File.join(filename, , "metadata")

    File.open(content,'wb') { |f| f << filedata }

     = (content, request)
    File.open(,'w') do |f|
      f << YAML::dump()
    end

    obj = S3Object.new
    obj.name = object_name
    obj.md5 = [:md5]
    obj.content_type = [:content_type]
    obj.content_disposition = [:content_disposition]
    obj.content_encoding = [:content_encoding] # if metadata_struct[:content_encoding]
    obj.size = [:size]
    obj.modified_date = [:modified_date]

    bucket.add(obj)
    return obj
  rescue
    unless @quiet_mode
      puts $!
      $!.backtrace.each { |line| puts line }
    end
    return nil
  end
end