public static S3PostUploadSignedPolicy GetSignedPolicyFromXml(string policyXml)
{
var reader = new StringReader(policyXml);
XmlSerializer serializer = new XmlSerializer(typeof(S3PostUploadSignedPolicy));
S3PostUploadSignedPolicy policy;
try
{
policy = serializer.Deserialize(reader) as S3PostUploadSignedPolicy;
}
catch (Exception e)
{
throw new ArgumentException("Could not parse XML", e);
}
if (String.IsNullOrEmpty(policy.AccessKeyId))
throw new ArgumentException("XML Document requries 'AccessKeyId' field");
if (String.IsNullOrEmpty(policy.Policy))
throw new ArgumentException("XML Document requries 'Policy' field");
if (String.IsNullOrEmpty(policy.Signature))
throw new ArgumentException("XML Document requries 'Signature' field");
return policy;
}
}