public string GetPolicyString(string fileId, string redirectUrl) { var policy = new UploadPolicy(DateTime.Now.AddHours(10)); policy.AddCondition(new List <string> { "eq", "$bucket", BucketName }); policy.AddCondition(new List <string> { "eq", "$acl", "public-read" }); policy.AddCondition(new List <string> { "content-length-range", "0", "100000000" }); policy.AddCondition(new List <string> { "starts-with", "$key", "" }); //policy.AddCondition(new List<string> { "eq", "$redirect", redirectUrl }); var ser = new DataContractJsonSerializer(typeof(UploadPolicy)); var ms = new MemoryStream(); ser.WriteObject(ms, policy); var json = Encoding.Default.GetString(ms.ToArray()); return(json); }
public string GetPolicyString(string fileId, string redirectUrl) { var policy = new UploadPolicy(DateTime.Now.AddHours(10)); policy.AddCondition(new List<string> { "eq", "$bucket", BucketName }); policy.AddCondition(new List<string> { "eq", "$acl", "private" }); policy.AddCondition(new List<string> { "content-length-range", "0", "100000000" }); policy.AddCondition(new List<string> { "eq", "$key", fileId }); policy.AddCondition(new List<string> { "eq", "$redirect", redirectUrl }); var ser = new DataContractJsonSerializer(typeof(UploadPolicy)); var ms = new MemoryStream(); ser.WriteObject(ms, policy); var json = Encoding.Default.GetString(ms.ToArray()); return json; }