# File lib/capybara-screenshot/s3_saver.rb, line 35
      def save_and_upload_screenshot
        save_and do |type, local_file_path|
          File.open(local_file_path) do |file|
            s3_upload_path = "#{@key_prefix}#{File.basename(local_file_path)}"

            object_payload = {
              bucket: bucket_name,
              key: s3_upload_path,
              body: file
            }

            object_payload.merge!(object_configuration) unless object_configuration.empty?

            s3_client.put_object(
                object_payload
            )

            s3_region = s3_client.get_bucket_location(bucket: bucket_name).location_constraint

            send("#{type}_path=", "https://#{bucket_name}.s3-#{s3_region}.amazonaws.com/#{s3_upload_path}")
          end
        end
      end