def s3_upload_policy_document
      policy = {
        'expiration' => 5.minutes.from_now.utc.xmlschema,
        'conditions' => [
          {'bucket' => config.bucket},
          {'acl' => s3_acl},
          {'success_action_status' => '200'},
          {'key' => key},
          ['content-length-range', 0, max_upload_size]
        ]
      }

      if attachment_filename
        policy['conditions'] << {"Content-Disposition" => %Q{attachment; filename="#{attachment_filename}"}}
      end

      if content_type
        policy['conditions'] << {"Content-Type" => content_type}
      end

      encode(policy.to_json)
    end
def s3_upload_policy_document
      policy = {
        'expiration' => 5.minutes.from_now.utc.xmlschema,
        'conditions' => [
          {'bucket' => config.bucket},
          {'acl' => s3_acl},
          {'success_action_status' => '200'},
          {'key' => key},
          ['content-length-range', 0, max_upload_size]
        ]
      }

      if attachment_filename
        policy['conditions'] << {"Content-Disposition" => %Q{attachment; filename="#{attachment_filename}"}}
      end

      if content_type
        policy['conditions'] << {"Content-Type" => content_type}
      end

      encode(policy.to_json)
    end
generate the policy document that amazon is expecting.