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)
metadata_dir = File.join(filename, FAKE_S3_METADATA_DIR)
FileUtils.mkdir_p(metadata_dir)
content = File.join(filename, FAKE_S3_METADATA_DIR, "content")
metadata = File.join(filename, FAKE_S3_METADATA_DIR, "metadata")
File.open(content,'wb') { |f| f << filedata }
metadata_struct = create_metadata(content, request)
File.open(metadata,'w') do |f|
f << YAML::dump(metadata_struct)
end
obj = S3Object.new
obj.name = object_name
obj.md5 = metadata_struct[:md5]
obj.content_type = metadata_struct[:content_type]
obj.content_disposition = metadata_struct[:content_disposition]
obj.content_encoding = metadata_struct[:content_encoding]
obj.size = metadata_struct[:size]
obj.modified_date = metadata_struct[:modified_date]
bucket.add(obj)
return obj
rescue
unless @quiet_mode
puts $!
$!.backtrace.each { |line| puts line }
end
return nil
end
end
|