Method: FakeS3::FileStore#create_metadata
- Defined in:
- lib/fakes3/file_store.rb
#create_metadata(content, request) ⇒ Object
TODO: abstract getting meta data from request.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/fakes3/file_store.rb', line 290 def (content, request) = {} [:md5] = Digest::MD5.file(content).hexdigest [:content_type] = request.header["content-type"].first if request.header['content-disposition'] [:content_disposition] = request.header['content-disposition'].first end content_encoding = request.header["content-encoding"].first [:content_encoding] = content_encoding #if content_encoding # metadata[:content_encoding] = content_encoding #end [:size] = File.size(content) [:modified_date] = File.mtime(content).utc.iso8601(SUBSECOND_PRECISION) [:amazon_metadata] = {} [:custom_metadata] = {} # Add custom metadata from the request header request.header.each do |key, value| match = /^x-amz-([^-]+)-(.*)$/.match(key) next unless match if match[1].eql?('meta') && (match_key = match[2]) [:custom_metadata][match_key] = value.join(', ') next end [:amazon_metadata][key.gsub(/^x-amz-/, '')] = value.join(', ') end return end |