lib/fakes3/file_store.rb in fakes3-1.1.0 vs lib/fakes3/file_store.rb in fakes3-1.2.0
- old
+ new
@@ -83,11 +83,14 @@
real_obj = S3Object.new
obj_root = File.join(@root,bucket,object_name,FAKE_S3_METADATA_DIR)
metadata = File.open(File.join(obj_root, "metadata")) { |file| YAML::load(file) }
real_obj.name = object_name
real_obj.md5 = metadata[:md5]
- real_obj.content_type = metadata.fetch(:content_type) { "application/octet-stream" }
+ real_obj.content_type = request.query['response-content-type'] ||
+ metadata.fetch(:content_type) { "application/octet-stream" }
+ real_obj.content_disposition = request.query['response-content-disposition'] ||
+ metadata[:content_disposition]
real_obj.content_encoding = metadata.fetch(:content_encoding) # if metadata.fetch(:content_encoding)
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).utc.iso8601(SUBSECOND_PRECISION)
real_obj.modified_date = metadata.fetch(:modified_date) do
@@ -149,10 +152,11 @@
obj = S3Object.new
obj.name = dst_name
obj.md5 = src_metadata[:md5]
obj.content_type = src_metadata[:content_type]
+ obj.content_disposition = src_metadata[:content_disposition]
obj.content_encoding = src_metadata[:content_encoding] # if src_metadata[:content_encoding]
obj.size = src_metadata[:size]
obj.modified_date = src_metadata[:modified_date]
src_bucket.find(src_name)
@@ -204,10 +208,11 @@
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] # if metadata_struct[:content_encoding]
obj.size = metadata_struct[:size]
obj.modified_date = metadata_struct[:modified_date]
bucket.add(obj)
@@ -267,9 +272,12 @@
# TODO: abstract getting meta data from request.
def create_metadata(content, request)
metadata = {}
metadata[:md5] = Digest::MD5.file(content).hexdigest
metadata[:content_type] = request.header["content-type"].first
+ if request.header['content-disposition']
+ metadata[:content_disposition] = request.header['content-disposition'].first
+ end
content_encoding = request.header["content-encoding"].first
metadata[:content_encoding] = content_encoding
#if content_encoding
# metadata[:content_encoding] = content_encoding
#end