lib/fakes3/file_store.rb in fakes3-0.1.5 vs lib/fakes3/file_store.rb in fakes3-0.1.5.2
- old
+ new
@@ -79,10 +79,13 @@
real_obj.name = object_name
real_obj.md5 = metadata[:md5]
real_obj.content_type = metadata.fetch(:content_type) { "application/octet-stream" }
#real_obj.io = File.open(File.join(obj_root,"content"),'rb')
real_obj.io = RateLimitableFile.open(File.join(obj_root,"content"),'rb')
+ real_obj.size = metadata.fetch(:size) { 0 }
+ real_obj.creation_date = File.ctime(obj_root).iso8601()
+ real_obj.modified_date = metadata.fetch(:modified_date) { File.mtime(File.join(obj_root,"content")).iso8601() }
return real_obj
rescue
puts $!
$!.backtrace.each { |line| puts line }
return nil
@@ -124,10 +127,12 @@
obj = S3Object.new
obj.name = dst_name
obj.md5 = src_metadata[:md5]
obj.content_type = src_metadata[:content_type]
+ obj.size = src_metadata[:size]
+ obj.modified_date = src_metadata[:modified_date]
src_obj = src_bucket.find(src_name)
dst_bucket.add(obj)
src_bucket.remove(src_obj)
return obj
@@ -155,18 +160,22 @@
end
metadata_struct = {}
metadata_struct[:md5] = md5.hexdigest
metadata_struct[:content_type] = request.header["content-type"].first
+ metadata_struct[:size] = File.size(content)
+ metadata_struct[:modified_date] = File.mtime(content).iso8601()
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.size = metadata_struct[:size]
+ obj.modified_date = metadata_struct[:modified_date]
bucket.add(obj)
return obj
rescue
puts $!