class Google::Cloud::Storage::File::SignerV4

def post_object issuer: nil,

def post_object issuer: nil,
                client_email: nil,
                signing_key: nil,
                private_key: nil,
                signer: nil,
                expires: nil,
                fields: nil,
                conditions: nil,
                scheme: "https",
                virtual_hosted_style: nil,
                bucket_bound_hostname: nil
  i = determine_issuer issuer, client_email
  s = determine_signing_key signing_key, private_key, signer
  now = Time.now.utc
  base_fields = required_fields i, now
  post_fields = fields.dup || {}
  post_fields.merge! base_fields
  p = {}
  p["conditions"] = policy_conditions base_fields, conditions, fields
  expires ||= 60 * 60 * 24
  p["expiration"] = (now + expires).strftime "%Y-%m-%dT%H:%M:%SZ"
  policy_str = escape_characters p.to_json
  policy = Base64.strict_encode64(policy_str).force_encoding "utf-8"
  signature = generate_signature s, policy
  post_fields["x-goog-signature"] = signature
  post_fields["policy"] = policy
  url = post_object_ext_url scheme, virtual_hosted_style, bucket_bound_hostname
  hostname = "#{url}#{bucket_path path_style?(virtual_hosted_style, bucket_bound_hostname)}"
  Google::Cloud::Storage::PostObject.new hostname, post_fields
end