Exemple #1
0
        public async static Task Run(MinioClient client,
                                     string bucketName = "my-bucketname",
                                     string objectName = "my-objectname")
        {
            // default value for expiration is 2 minutes
            DateTime expiration = DateTime.UtcNow.AddMinutes(2);

            // DefaultPolicy defaultPolicy = delegate (string bucketName,
            //                                         string objectName,
            //                                         DateTime expiration)
            // {
            PostPolicy form = new PostPolicy();

            form.SetKey(objectName);
            form.SetBucket(bucketName);
            form.SetExpires(expiration);
            // return policy;
            // };
            // PostPolicy postPolicy = defaultPolicy(bucketName,
            //                                       objectName,
            //                                       expiration);

            PresignedPostPolicyArgs args = new PresignedPostPolicyArgs()
                                           .WithBucket(bucketName)
                                           .WithObject(objectName)
                                           .WithPolicy(form);

            var tuple = await client.PresignedPostPolicyAsync(form);

            string curlCommand = "curl -k --insecure -X POST";

            foreach (KeyValuePair <string, string> pair in tuple.Item2)
            {
                curlCommand = curlCommand + $" -F {pair.Key}={pair.Value}";
            }
            curlCommand = curlCommand + " -F file=@/etc/issue " + tuple.Item1 + bucketName + "/";
        }
Exemple #2
0
 public PresignedPostPolicyResponse(PresignedPostPolicyArgs args, Uri URI)
 {
     URIPolicyTuple = Tuple.Create(URI.AbsolutePath, args.Policy.GetFormData());
 }