Пример #1
0
        // Put an object from a local stream into bucket
        public async static Task Run(MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string objectName = "my-object-name",
                                     string fileName   = "location-of-file")
        {
            try
            {
                Console.WriteLine("Running example for API: PutObjectAsync with Tags");
                var tags = new Dictionary <string, string>
                {
                    { "Test-TagKey", "Test-TagValue" }
                };
                PutObjectArgs args = new PutObjectArgs()
                                     .WithBucket(bucketName)
                                     .WithObject(objectName)
                                     .WithContentType("application/octet-stream")
                                     .WithFileName(fileName)
                                     .WithTagging(Tagging.GetObjectTags(tags));
                await minio.PutObjectAsync(args);

                Console.WriteLine($"Uploaded object {objectName} to bucket {bucketName}");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine($"[Bucket]  Exception: {e}");
            }
        }
 // Copy object from one bucket to another, replace tags in the copied object
 public async static Task Run(MinioClient minio,
                              string fromBucketName = "from-bucket-name",
                              string fromObjectName = "from-object-name",
                              string destBucketName = "dest-bucket",
                              string destObjectName = " to-object-name")
 {
     try
     {
         Console.WriteLine("Running example for API: CopyObjectAsync with Tags");
         var tags = new Dictionary <string, string>
         {
             { "Test-TagKey", "Test-TagValue" },
         };
         CopySourceObjectArgs cpSrcArgs = new CopySourceObjectArgs()
                                          .WithBucket(fromBucketName)
                                          .WithObject(fromObjectName);
         CopyObjectArgs args = new CopyObjectArgs()
                               .WithBucket(destBucketName)
                               .WithObject(destObjectName)
                               .WithTagging(Tagging.GetObjectTags(tags))
                               .WithReplaceTagsDirective(true)
                               .WithCopyObjectSource(cpSrcArgs);
         await minio.CopyObjectAsync(args).ConfigureAwait(false);
     }
     catch (Exception e)
     {
         Console.WriteLine("[Bucket]  Exception: {0}", e);
     }
 }
Пример #3
0
        // Set Tags for the object
        public async static Task Run(MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string objectName = "my-object-name",
                                     Dictionary <string, string> tags = null,
                                     string versionId = null)
        {
            try
            {
                Console.WriteLine("Running example for API: SetObjectTags");
                var args = new SetObjectTagsArgs()
                           .WithBucket(bucketName)
                           .WithObject(objectName)
                           .WithVersionId(versionId)
                           .WithTagging(Tagging.GetObjectTags(tags));
                await minio.SetObjectTagsAsync(args);

                Console.WriteLine($"Tags set for object {bucketName}/{objectName}.");
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine($"[Object]  Exception: {e}");
            }
        }
 public SetBucketTagsArgs WithTagging(Tagging tags)
 {
     BucketTags = Tagging.GetObjectTags(tags.GetTags());
     return(this);
 }