Beispiel #1
0
        public static string GeneratePostPolicyJsonBase64(this PolicyConditions conds, DateTime expiration)
        {
            if (conds == null)
            {
                throw new ArgumentNullException("conds");
            }

            var formatedExpiration = DateUtils.FormatIso8601Date(expiration);
            var jsonizedExpiration = string.Format("\"expiration\":\"{0}\"", formatedExpiration);
            var jsonizedConds      = conds.Jsonize();
            var json = string.Format("{{{0},{1}}}", jsonizedExpiration, jsonizedConds);

            return(Convert.ToBase64String(Encoding.UTF8.GetBytes(json)));
        }
Beispiel #2
0
        /// <inheritdoc/>
        public string GeneratePostPolicy(DateTime expiration, PolicyConditions conds)
        {
            if (conds == null)
            {
                throw new ArgumentNullException("conds");
            }

            var formatedExpiration = DateUtils.FormatIso8601Date(expiration);
            //var jsonizedExpiration = string.Format("\"expiration\":\"{0}\"", formatedExpiration);
            var jsonizedExpiration = $"\"expiration\":\"{formatedExpiration}\"";
            var jsonizedConds      = conds.Jsonize();

            //return String.Format("{{{0},{1}}}", jsonizedExpiration, jsonizedConds);
            return($"{{{jsonizedExpiration},{jsonizedConds}}}");
        }
 public static Task <string> GeneratePostPolicyAsync(this IOss client, DateTime expiration, PolicyConditions conds)
 {
     return(Task.Factory.StartNew(() => client.GeneratePostPolicy(expiration, conds)));
 }