Exemple #1
0
        // Set bucket policy
        public async static Task Run(MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.WriteLine("Running example for API: DeletePolicyAsync");
                var args = new RemovePolicyArgs()
                           .WithBucket(bucketName);
                await minio.RemovePolicyAsync(args);

                Console.WriteLine($"Policy previously set for the bucket {bucketName} removed.");
                try
                {
                    var getArgs = new GetPolicyArgs()
                                  .WithBucket(bucketName);
                    string policy = await minio.GetPolicyAsync(getArgs);
                }
                catch (UnexpectedMinioException e)
                {
                    Console.WriteLine($"GetPolicy operation for {bucketName} result: {e.ServerMessage}");
                }
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine($"[Bucket]  Exception: {e}");
            }
        }
Exemple #2
0
        /// <summary>
        /// 移除全部存储桶的权限
        /// 如果要单独移除某个桶的权限,可以使用SetPolicyAsync,并将StatementItem中的IsDelete设置为true
        /// </summary>
        /// <param name="bucketName">存储桶名称。</param>
        /// <returns></returns>
        public async Task <bool> RemovePolicyAsync(string bucketName)
        {
            if (string.IsNullOrEmpty(bucketName))
            {
                throw new ArgumentNullException(nameof(bucketName));
            }
            var args = new RemovePolicyArgs().WithBucket(bucketName);
            await _client.RemovePolicyAsync(args);

            return(true);
        }