module AWS::S3::DataOptions

def try_to_determine_content_length options

This is only done when a content length is not already provided.
Attempts to determine the content length of the :data option.
def try_to_determine_content_length options
  unless options[:content_length]
    data = options[:data]
    length = case
      when data.respond_to?(:path) && data.path then File.size(data.path)
      when data.respond_to?(:bytesize) then data.bytesize
      when data.respond_to?(:size)     then data.size
      when data.respond_to?(:length)   then data.length
      else nil
    end
    options[:content_length] = length if length
  end
end