Beispiel #1
0
        // Copy object from one bucket to another
        public async static Task Run(Minio.MinioClient minio,
                                     string fromBucketName = "from-bucket-name",
                                     string fromObjectName = "from-object-name",
                                     string destBucketName = "dest-bucket",
                                     string destObjectName = "to-object-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: CopyObjectAsync");

                // Optionally pass copy conditions to replace metadata on destination object with custom metadata
                CopyConditions copyCond = new CopyConditions();
                copyCond.SetReplaceMetadataDirective();

                // set custom metadata
                var metadata = new Dictionary <string, string>
                {
                    { "Content-Type", "application/css" },
                    { "X-Amz-Meta-Mynewkey", "my-new-value" }
                };
                await minio.CopyObjectAsync(fromBucketName,
                                            fromObjectName,
                                            destBucketName,
                                            destObjectName,
                                            copyConditions : copyCond,
                                            metadata : metadata);

                Console.Out.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #2
0
        // Copy object from one bucket to another
        public async static Task Run(Minio.MinioClient minio,
                                     string fromBucketName        = "from-bucket-name",
                                     string fromObjectName        = "from-object-name",
                                     string destBucketName        = "dest-bucket",
                                     string destObjectName        = "to-object-name",
                                     ServerSideEncryption sseSrc  = null,
                                     ServerSideEncryption sseDest = null)
        {
            try
            {
                Console.Out.WriteLine("Running example for API: CopyObjectAsync");
                // Optionally pass copy conditions
                await minio.CopyObjectAsync(fromBucketName,
                                            fromObjectName,
                                            destBucketName,
                                            destObjectName,
                                            copyConditions : null,
                                            sseSrc : sseSrc,
                                            sseDest : sseDest);

                Console.Out.WriteLine("Copied object {0} from bucket {1} to bucket {2}", fromObjectName, fromBucketName, destBucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #3
0
        public SingleBucketFileStorageService(
            string bucket,
            string endpoint,
            string?publicEndpoint,
            string accessKey,
            string secretKey,
            bool hasSsl,
            bool hasPublicSsl,
            ILogger <SingleBucketFileStorageService> logger
            )
        {
            client = new Minio.MinioClient(endpoint, accessKey, secretKey);
            if (hasSsl)
            {
                client = client.WithSSL();
            }
            this.bucket         = bucket;
            this.endpoint       = endpoint;
            this.publicEndpoint = publicEndpoint;
            var endpointUri = new UriBuilder(publicEndpoint ?? this.endpoint);

            if (endpointUri.Host == null || endpointUri.Host == "" || endpointUri.Scheme != null || endpointUri.Scheme != "")
            {
            }
            else
            {
                endpointUri.Scheme = hasPublicSsl ? "https" : "http";
            }
            this.publicEndpointUri = new Uri(endpointUri.Uri, bucket + "/");
            logger.LogInformation("Set up public endpoint as {0}", publicEndpointUri.ToString());
            this.hasSsl = hasSsl;
            this.logger = logger;
        }
Beispiel #4
0
        // Put an object from a local stream into bucket
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string objectName = "my-object-name",
                                     string fileName   = "location-of-file")
        {
            try
            {
                byte[] bs = File.ReadAllBytes(fileName);
                using (System.IO.MemoryStream filestream = new System.IO.MemoryStream(bs))
                {
                    if (filestream.Length < (5 * MB))
                    {
                        Console.Out.WriteLine("Running example for API: PutObjectAsync with Stream");
                    }
                    else
                    {
                        Console.Out.WriteLine("Running example for API: PutObjectAsync with Stream and MultiPartUpload");
                    }

                    await minio.PutObjectAsync(bucketName,
                                               objectName,
                                               filestream,
                                               filestream.Length,
                                               "application/octet-stream");
                }


                Console.Out.WriteLine("Uploaded object " + objectName + " to bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #5
0
        public MinioStorageProvider(string endpoint, string accessKey, string secret)
        {
            if (string.IsNullOrWhiteSpace(endpoint))
            {
                throw new ArgumentNullException(nameof(endpoint));
            }

            _client = new Minio.MinioClient(endpoint, accessKey, secret);
        }
Beispiel #6
0
        private async static Task Run(Minio.MinioClient minio, IFormFile _request, string bucketName, string location, Guid id, string fileLocation)
        {
            if (!Directory.Exists(fileLocation))
            {
                Directory.CreateDirectory(fileLocation);
            }

            string FilePath = "";

            using (var fileStream = new FileStream(fileLocation + _request.FileName, FileMode.Create))
            {
                await _request.CopyToAsync(fileStream);

                FilePath = fileStream.Name;
            }

            //var objectName = _request.FileName;
            var objectName = id.ToString();
            var filePath   = FilePath;

            var contentType = _request.ContentType;

            //var contentType = "";
            //if (fileType == "audio")
            //{
            //    contentType = "audio/mp3";
            //}
            //else if (fileType == "video")
            //{
            //    contentType = "video/mp4";
            //}

            try
            {
                // Make a bucket on the server, if not already present.
                bool found = await minio.BucketExistsAsync(bucketName);

                if (!found)
                {
                    await minio.MakeBucketAsync(bucketName, location);
                }
                // Upload a file to bucket.
                await minio.PutObjectAsync(bucketName, objectName, filePath, contentType);

                System.IO.File.Delete(filePath);
                Console.WriteLine("Successfully uploaded " + objectName);
            }
            catch (MinioException e)
            {
                logger.Error(e);
                Console.WriteLine("File Upload Error: {0}", e.Message);
            }
        }
Beispiel #7
0
 // Get stats on a object
 public async static Task Run(Minio.MinioClient minio, 
                              string bucketName = "my-bucket-name",
                              string bucketObject="my-object-name")
 {
     try
     {
         Console.Out.WriteLine("Running example for API: StatObjectAsync");
         ObjectStat statObject = await minio.StatObjectAsync(bucketName, bucketObject);
         Console.Out.WriteLine("Details of the object " + bucketObject + " are " + statObject);
         Console.Out.WriteLine();
     }
     catch (Exception e)
     {
         Console.WriteLine("[StatObject] {0}-{1}  Exception: {2}",bucketName, bucketObject, e);
     }
 }
        // Get bucket notifications - this works only with AWS endpoint
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: GetBucketNotificationsAsync");
                BucketNotification notifications = await minio.GetBucketNotificationsAsync(bucketName);

                Console.Out.WriteLine("Notifications is " + notifications.ToXML() + " for bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.Out.WriteLine("Error parsing bucket notifications - make sure that you are running this call against AWS end point: " + e.Message);
            }
        }
Beispiel #9
0
        // Make a bucket
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: MakeBucketAsync");
                await minio.MakeBucketAsync(bucketName);

                Console.Out.WriteLine("Created bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #10
0
        // Get bucket policy
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string prefix     = "")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: GetPolicyAsync");
                PolicyType policy = await minio.GetPolicyAsync(bucketName);

                Console.Out.WriteLine("Current Policy is " + policy.ToString() + " for bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
        // Removes all bucket notifications
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: RemoveAllBucketNotificationAsync");

                await minio.RemoveAllBucketNotificationsAsync(bucketName);

                Console.Out.WriteLine("Notifications successfully removed from the bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #12
0
        public MinIOController(IWebHostEnvironment appEnvironment)
        {
            try
            {
                _appEnvironment = appEnvironment;

                defaultBucketName = Configuration["MinioRepository:defaultBucket"];

                var endpoint  = Configuration["MinioRepository:endpoint"];
                var accessKey = Configuration["MinioRepository:accessKey"];
                var secretKey = Configuration["MinioRepository:secretKey"];
                minioClient = new Minio.MinioClient(endpoint, accessKey, secretKey).WithSSL();
            }
            catch (Exception)
            {
                throw;
            }
        }
        // Set bucket policy
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: SetPolicyAsync");
                string policyJson = $@"{{""Version"":""2012-10-17"",""Statement"":[{{""Action"":[""s3:GetBucketLocation""],""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}""],""Sid"":""""}},{{""Action"":[""s3:ListBucket""],""Condition"":{{""StringEquals"":{{""s3:prefix"":[""foo"",""prefix/""]}}}},""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}""],""Sid"":""""}},{{""Action"":[""s3:GetObject""],""Effect"":""Allow"",""Principal"":{{""AWS"":[""*""]}},""Resource"":[""arn:aws:s3:::{bucketName}/foo*"",""arn:aws:s3:::{bucketName}/prefix/*""],""Sid"":""""}}]}}";
                // Change policy type parameter
                await minio.SetPolicyAsync(bucketName, policyJson);

                Console.Out.WriteLine("Policy " + policyJson + " set for the bucket " + bucketName + " successfully");
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #14
0
        // Download object from bucket into local file
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string objectName = "my-object-name",
                                     string fileName   = "local-filename")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: GetObjectAsync");
                File.Delete(fileName);
                await minio.GetObjectAsync(bucketName, objectName, fileName);

                Console.WriteLine("Downloaded the file " + fileName + " from bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #15
0
        // Put an object from a local stream into bucket
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName        = "my-bucket-name",
                                     string objectName        = "my-object-name",
                                     string fileName          = "location-of-file",
                                     ServerSideEncryption sse = null)
        {
            try
            {
                byte[] bs = File.ReadAllBytes(fileName);
                using (System.IO.MemoryStream filestream = new System.IO.MemoryStream(bs))
                {
                    if (filestream.Length < (5 * MB))
                    {
                        Console.Out.WriteLine("Running example for API: PutObjectAsync with Stream");
                    }
                    else
                    {
                        Console.Out.WriteLine("Running example for API: PutObjectAsync with Stream and MultiPartUpload");
                    }
                    var metaData = new Dictionary <string, string>()
                    {
                        { "X-Amz-Meta-Test", "Test  Test" }
                    };
                    await minio.PutObjectAsync(bucketName,
                                               objectName,
                                               filestream,
                                               filestream.Length,
                                               "application/octet-stream",
                                               metaData : metaData,
                                               sse : sse);
                }


                Console.Out.WriteLine("Uploaded object " + objectName + " to bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #16
0
        // Upload object to bucket from file
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name",
                                     string objectName = "my-object-name",
                                     string fileName   = "from where")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: PutObjectAsync with FileName");
                await minio.PutObjectAsync(bucketName,
                                           objectName,
                                           fileName,
                                           contentType : "application/octet-stream");

                Console.Out.WriteLine("Uploaded object " + objectName + " to bucket " + bucketName);
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #17
0
        // Set bucket policy
        public async static Task Run(Minio.MinioClient minio,
                                     PolicyType policy,
                                     string bucketName   = "my-bucket-name",
                                     string objectPrefix = "")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: SetPolicyAsync");
                // Change policy type parameter
                await minio.SetPolicyAsync(bucketName,
                                           objectPrefix,
                                           policy);

                Console.Out.WriteLine("Policy " + policy.ToString() + " set for the bucket " + bucketName + " successfully");
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #18
0
        public bool minioAudioVideoUpload(IFormFile formFile, Guid id)
        {
            var appSetting = new MinIoConfig()
            {
                EndPoint    = _minIoConfig.EndPoint,
                AccessKey   = _minIoConfig.AccessKey,
                SecretKey   = _minIoConfig.SecretKey,
                BucketName  = _minIoConfig.BucketName,
                Location    = _minIoConfig.Location,
                MinIoForDev = _minIoConfig.MinIoForDev,
                FilePath    = _minIoConfig.FilePath
            };

            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  EndPoint : {appSetting.EndPoint}");
            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  AccessKey : {appSetting.AccessKey}");
            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  SecretKey : {appSetting.SecretKey}");
            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  BucketName : {appSetting.BucketName}");
            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  Location : {appSetting.Location}");
            logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  MinIoForDev : {appSetting.MinIoForDev}");
            try
            {
                if (appSetting.MinIoForDev != true)
                {
                    var minio = new Minio.MinioClient(appSetting.EndPoint, appSetting.AccessKey, appSetting.SecretKey).WithSSL();
                    Run(minio, formFile, appSetting.BucketName, appSetting.Location, id, appSetting.FilePath).Wait();
                    return(true);
                }
                else
                {
                    var minio = new Minio.MinioClient(appSetting.EndPoint, appSetting.AccessKey, appSetting.SecretKey);
                    Run(minio, formFile, appSetting.BucketName, appSetting.Location, id, appSetting.FilePath).Wait();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(false);
            }
        }
        // Set bucket notifications. The resource ARN needs to exist on AWS with correct permissions.
        // For further info: see http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
        public async static Task Run(Minio.MinioClient minio,
                                     string bucketName = "my-bucket-name")
        {
            try
            {
                Console.Out.WriteLine("Running example for API: SetBucketNotificationAsync");
                BucketNotification notification = new BucketNotification();

                // Uncomment the code below and change Arn and event types to configure.

                /*
                 * Arn topicArn = new Arn("aws", "sns", "us-west-1", "730234153608", "topicminio");
                 * TopicConfig topicConfiguration = new TopicConfig(topicArn);
                 * List<EventType> events = new List<EventType>(){ EventType.ObjectCreatedPut , EventType.ObjectCreatedCopy };
                 * topicConfiguration.AddEvents(events);
                 * topicConfiguration.AddFilterPrefix("images");
                 * topicConfiguration.AddFilterSuffix("pg");
                 * notification.AddTopic(topicConfiguration);
                 *
                 * LambdaConfig lambdaConfiguration = new LambdaConfig("arn:aws:lambda:us-west-1:123434153608:function:lambdak1");
                 * lambdaConfiguration.AddEvents(new List<EventType>() { EventType.ObjectRemovedDelete });
                 * lambdaConfiguration.AddFilterPrefix("java");
                 * lambdaConfiguration.AddFilterSuffix("java");
                 * notification.AddLambda(lambdaConfiguration);
                 *
                 * QueueConfig queueConfiguration = new QueueConfig("arn:aws:sqs:us-west-1:123434153608:testminioqueue1");
                 * queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload });
                 * notification.AddQueue(queueConfiguration);
                 */
                await minio.SetBucketNotificationsAsync(bucketName,
                                                        notification);

                Console.Out.WriteLine("Notifications set for the bucket " + bucketName + "were set successfully");
                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #20
0
        // List objects matching optional prefix in a specified bucket.
        public static void Run(Minio.MinioClient minio,
                               string bucketName = "my-bucket-name",
                               string prefix     = null,
                               bool recursive    = true)
        {
            try
            {
                Console.Out.WriteLine("Running example for API: ListObjectsAsync");
                IObservable <Item> observable = minio.ListObjectsAsync(bucketName, prefix, recursive);

                IDisposable subscription = observable.Subscribe(
                    item => Console.WriteLine("Object: {0}", item.Key),
                    ex => Console.WriteLine("OnError: {0}", ex),
                    () => Console.WriteLine("Listed all objects in bucket " + bucketName + "\n"));

                // subscription.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("[Bucket]  Exception: {0}", e);
            }
        }
Beispiel #21
0
        // List incomplete uploads on the bucket matching specified prefix
        public static void Run(Minio.MinioClient minio,
                               string bucketName = "my-bucket-name",
                               string prefix     = "my-object-name",
                               bool recursive    = true)
        {
            try
            {
                Console.Out.WriteLine("Running example for API: ListIncompleteUploads");

                IObservable <Upload> observable = minio.ListIncompleteUploads(bucketName, prefix, recursive);

                IDisposable subscription = observable.Subscribe(
                    item => Console.WriteLine("OnNext: {0}", item.Key),
                    ex => Console.WriteLine("OnError: {0}", ex.Message),
                    () => Console.WriteLine("Listed the pending uploads to bucket " + bucketName));

                Console.Out.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e);
            }
        }
Beispiel #22
0
        public static void Main(string[] args)
        {
            String endPoint    = null;
            String accessKey   = null;
            String secretKey   = null;
            bool   enableHTTPS = false;

            if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
            {
                endPoint  = Environment.GetEnvironmentVariable("SERVER_ENDPOINT");
                accessKey = Environment.GetEnvironmentVariable("ACCESS_KEY");
                secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
                if (Environment.GetEnvironmentVariable("ENABLE_HTTPS") != null)
                {
                    enableHTTPS = Environment.GetEnvironmentVariable("ENABLE_HTTPS").Equals("1");
                }
            }
            else
            {
                endPoint    = "play.minio.io:9000";
                accessKey   = "Q3AM3UQ867SPQQA43P2F";
                secretKey   = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
                enableHTTPS = true;
            }

            // WithSSL() enables SSL support in Minio client
            MinioClient minioClient = null;

            if (enableHTTPS)
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey).WithSSL();
            }
            else
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey);
            }

            try
            {
                // Assign parameters before starting the test
                string        bucketName     = GetRandomName();
                string        smallFileName  = CreateFile(1 * UNIT_MB);
                string        bigFileName    = CreateFile(6 * UNIT_MB);
                string        objectName     = GetRandomName();
                string        destBucketName = GetRandomName();
                string        destObjectName = GetRandomName();
                List <string> objectsList    = new List <string>();
                for (int i = 0; i < 10; i++)
                {
                    objectsList.Add(objectName + i.ToString());
                }
                // Set app Info
                minioClient.SetAppInfo("app-name", "app-version");

                // Set HTTP Tracing On
                // minioClient.SetTraceOn();


                // Set HTTP Tracing Off
                // minioClient.SetTraceOff();
                // Check if bucket exists
                Cases.BucketExists.Run(minioClient, bucketName).Wait();

                // Create a new bucket
                Cases.MakeBucket.Run(minioClient, bucketName).Wait();

                Cases.MakeBucket.Run(minioClient, destBucketName).Wait();


                // List all the buckets on the server
                Cases.ListBuckets.Run(minioClient).Wait();

                // Put an object to the new bucket
                Cases.PutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Get object metadata
                Cases.StatObject.Run(minioClient, bucketName, objectName).Wait();

                // List the objects in the new bucket
                Cases.ListObjects.Run(minioClient, bucketName);

                // Delete the file and Download the object as file
                Cases.GetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download partial object as file
                Cases.GetPartialObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Server side copyObject
                Cases.CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName).Wait();

                // Upload a File with PutObject
                Cases.FPutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download the object as file
                Cases.FGetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Automatic Multipart Upload with object more than 5Mb
                Cases.PutObject.Run(minioClient, bucketName, objectName, bigFileName).Wait();

                // List the incomplete uploads
                Cases.ListIncompleteUploads.Run(minioClient, bucketName);

                // Remove all the incomplete uploads
                Cases.RemoveIncompleteUpload.Run(minioClient, bucketName, objectName).Wait();

                // Set a policy for given bucket
                Cases.SetBucketPolicy.Run(minioClient, bucketName).Wait();
                // Get the policy for given bucket
                Cases.GetBucketPolicy.Run(minioClient, bucketName).Wait();

                // Set bucket notifications
                Cases.SetBucketNotification.Run(minioClient, bucketName).Wait();

                // Get bucket notifications
                Cases.GetBucketNotification.Run(minioClient, bucketName).Wait();

                // Remove all bucket notifications
                Cases.RemoveAllBucketNotifications.Run(minioClient, bucketName).Wait();

                // Get the presigned url for a GET object request
                Cases.PresignedGetObject.Run(minioClient, bucketName, objectName).Wait();

                // Get the presigned POST policy curl url
                Cases.PresignedPostPolicy.Run(minioClient).Wait();

                // Get the presigned url for a PUT object request
                Cases.PresignedPutObject.Run(minioClient, bucketName, objectName).Wait();

                // Delete the list of objects
                Cases.RemoveObjects.Run(minioClient, bucketName, objectsList).Wait();

                // Delete the object
                Cases.RemoveObject.Run(minioClient, bucketName, objectName).Wait();

                // Delete the object
                Cases.RemoveObject.Run(minioClient, destBucketName, objectName).Wait();

                // Remove the buckets
                Cases.RemoveBucket.Run(minioClient, bucketName).Wait();
                Cases.RemoveBucket.Run(minioClient, destBucketName).Wait();

                // Remove the binary files created for test
                File.Delete(smallFileName);
                File.Delete(bigFileName);

                Console.ReadLine();
            }
            catch (MinioException ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
Beispiel #23
0
        public static void Main(string[] args)
        {
            String endPoint  = null;
            String accessKey = null;
            String secretKey = null;

#if NET452
            endPoint  = ConfigurationManager.AppSettings["Endpoint"];
            accessKey = ConfigurationManager.AppSettings["AccessKey"];
            secretKey = ConfigurationManager.AppSettings["SecretKey"];


            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12
                                                    | SecurityProtocolType.Tls11
                                                    | SecurityProtocolType.Tls12;
#endif
#if NETCOREAPP1_0
            endPoint  = "play.minio.io:9000";
            accessKey = "Q3AM3UQ867SPQQA43P2F";
            secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
#endif

            // WithSSL() enables SSL support in Minio client
            var minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey).WithSSL();

            try
            {
                // Assign parameters before starting the test
                string bucketName     = GetRandomName();
                string smallFileName  = CreateFile(1 * UNIT_MB);
                string bigFileName    = CreateFile(6 * UNIT_MB);
                string objectName     = GetRandomName();
                string destBucketName = GetRandomName();
                string destObjectName = GetRandomName();

                // Set app Info
                minioClient.SetAppInfo("app-name", "app-version");

                // Set HTTP Tracing On
                // minioClient.SetTraceOn();


                // Set HTTP Tracing Off
                // minioClient.SetTraceOff();

                // Check if bucket exists
                Cases.BucketExists.Run(minioClient, bucketName).Wait();

                // Create a new bucket
                Cases.MakeBucket.Run(minioClient, bucketName).Wait();

                Cases.MakeBucket.Run(minioClient, destBucketName).Wait();


                // List all the buckets on the server
                Cases.ListBuckets.Run(minioClient).Wait();

                // Put an object to the new bucket
                Cases.PutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Get object metadata
                Cases.StatObject.Run(minioClient, bucketName, objectName).Wait();

                // List the objects in the new bucket
                Cases.ListObjects.Run(minioClient, bucketName);

                // Delete the file and Download the object as file
                Cases.GetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download partial object as file
                Cases.GetPartialObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Server side copyObject
                Cases.CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName).Wait();

                // Upload a File with PutObject
                Cases.FPutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download the object as file
                Cases.FGetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Automatic Multipart Upload with object more than 5Mb
                Cases.PutObject.Run(minioClient, bucketName, objectName, bigFileName).Wait();

                // List the incomplete uploads
                Cases.ListIncompleteUploads.Run(minioClient, bucketName);

                // Remove all the incomplete uploads
                Cases.RemoveIncompleteUpload.Run(minioClient, bucketName, objectName).Wait();

                // Set a policy for given bucket
                Cases.SetBucketPolicy.Run(minioClient, PolicyType.READ_ONLY, bucketName).Wait();

                // Get the policy for given bucket
                Cases.GetBucketPolicy.Run(minioClient, bucketName).Wait();

                // Get the presigned url for a GET object request
                Cases.PresignedGetObject.Run(minioClient, bucketName, objectName).Wait();

                // Get the presigned POST policy curl url
                Cases.PresignedPostPolicy.Run(minioClient).Wait();

                // Get the presigned url for a PUT object request
                Cases.PresignedPutObject.Run(minioClient, bucketName, objectName).Wait();


                // Delete the object
                Cases.RemoveObject.Run(minioClient, bucketName, objectName).Wait();

                // Delete the object
                Cases.RemoveObject.Run(minioClient, destBucketName, objectName).Wait();

                // Remove the buckets
                Cases.RemoveBucket.Run(minioClient, bucketName).Wait();
                Cases.RemoveBucket.Run(minioClient, destBucketName).Wait();

                // Remove the binary files created for test
                File.Delete(smallFileName);
                File.Delete(bigFileName);

                Console.ReadLine();
            }
            catch (MinioException ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
Beispiel #24
0
        public static void Main(string[] args)
        {
            String endPoint    = null;
            String accessKey   = null;
            String secretKey   = null;
            bool   enableHTTPS = false;

            if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
            {
                endPoint  = Environment.GetEnvironmentVariable("SERVER_ENDPOINT");
                accessKey = Environment.GetEnvironmentVariable("ACCESS_KEY");
                secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
                if (Environment.GetEnvironmentVariable("ENABLE_HTTPS") != null)
                {
                    enableHTTPS = Environment.GetEnvironmentVariable("ENABLE_HTTPS").Equals("1");
                }
            }
            else
            {
                endPoint    = "172.16.131.38:9003";
                accessKey   = "LO47Y1RNP2LVJ1A495A3";
                secretKey   = "5nZWV/8v9WbuDd7Gvcdepqklp/P7D6S/hvIT19dV";
                enableHTTPS = false;
            }
#if NET452
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12
                                                    | SecurityProtocolType.Tls11
                                                    | SecurityProtocolType.Tls12;
#endif

            // WithSSL() enables SSL support in Minio client
            MinioClient minioClient = null;
            if (enableHTTPS)
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey).WithSSL();
            }
            else
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey);
            }

            try
            {
                // Assign parameters before starting the test
                //string bucketName = GetRandomName();
                string bucketName = "myleebucket";
                //string smallFileName = CreateFile(1 * UNIT_MB);
                //string bigFileName = CreateFile(6 * UNIT_MB);
                //string objectName = GetRandomName();
                string objectName = "objectlee";
                //string destBucketName = GetRandomName();
                //string destObjectName = GetRandomName();
                List <string> objectsList = new List <string>();
                for (int i = 0; i < 10; i++)
                {
                    objectsList.Add(objectName + i.ToString());
                }
                // Set app Info
                minioClient.SetAppInfo("app-name", "app-version");

                // Set HTTP Tracing On
                minioClient.SetTraceOn();


                // Set HTTP Tracing Off
                // minioClient.SetTraceOff();
                // Check if bucket exists
                Cases.BucketExists.Run(minioClient, bucketName).Wait();

                // Create a new bucket
                Cases.MakeBucket.Run(minioClient, bucketName).Wait();

                //Cases.MakeBucket.Run(minioClient, destBucketName).Wait();


                // List all the buckets on the server
                // Cases.ListBuckets.Run(minioClient).Wait();

                //// Put an object to the new bucket
                //Cases.PutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                //// Get object metadata
                //Cases.StatObject.Run(minioClient, bucketName, objectName).Wait();

                //// List the objects in the new bucket
                //Cases.ListObjects.Run(minioClient, bucketName);

                //// Delete the file and Download the object as file
                //Cases.GetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                //// Delete the file and Download partial object as file
                //Cases.GetPartialObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                //// Server side copyObject
                //Cases.CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName).Wait();

                //// Upload a File with PutObject
                //Cases.FPutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                //// Delete the file and Download the object as file
                //Cases.FGetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                //// Automatic Multipart Upload with object more than 5Mb
                //Cases.PutObject.Run(minioClient, bucketName, objectName, bigFileName).Wait();

                //// List the incomplete uploads
                //Cases.ListIncompleteUploads.Run(minioClient, bucketName);

                //// Remove all the incomplete uploads
                //Cases.RemoveIncompleteUpload.Run(minioClient, bucketName, objectName).Wait();

                //// Set a policy for given bucket
                //Cases.SetBucketPolicy.Run(minioClient, bucketName).Wait();
                //// Get the policy for given bucket
                //Cases.GetBucketPolicy.Run(minioClient, bucketName).Wait();

                //// Set bucket notifications
                //Cases.SetBucketNotification.Run(minioClient, bucketName).Wait();

                //// Get bucket notifications
                //Cases.GetBucketNotification.Run(minioClient, bucketName).Wait();

                //// Remove all bucket notifications
                //Cases.RemoveAllBucketNotifications.Run(minioClient, bucketName).Wait();

                //// Get the presigned url for a GET object request
                //Cases.PresignedGetObject.Run(minioClient, bucketName, objectName).Wait();

                //// Get the presigned POST policy curl url
                //Cases.PresignedPostPolicy.Run(minioClient).Wait();

                //// Get the presigned url for a PUT object request
                //Cases.PresignedPutObject.Run(minioClient, bucketName, objectName).Wait();

                //// Delete the list of objects
                //Cases.RemoveObjects.Run(minioClient, bucketName, objectsList).Wait();

                //// Delete the object
                //Cases.RemoveObject.Run(minioClient, bucketName, objectName).Wait();

                //// Delete the object
                //Cases.RemoveObject.Run(minioClient, destBucketName, objectName).Wait();

                //// Remove the buckets
                //Cases.RemoveBucket.Run(minioClient, bucketName).Wait();
                //Cases.RemoveBucket.Run(minioClient, destBucketName).Wait();

                // Remove the binary files created for test
                //File.Delete(smallFileName);
                //File.Delete(bigFileName);

                Console.ReadLine();
            }
            catch (MinioException ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
 public MinioStorageProvider(string endpoint, string accessKey, string secret)
 {
     _client = new Minio.MinioClient(endpoint, accessKey, secret);
 }
Beispiel #26
0
 public VideoController(Minio.MinioClient minioClient, IConfiguration configuration)
 {
     this.minioClient       = minioClient;
     this.defaultBucketName = configuration.GetSection("DevWeek:S3:DefaultBucketName").Get <string>();
 }
Beispiel #27
0
        public static void Main(string[] args)
        {
            String endPoint    = null;
            String accessKey   = null;
            String secretKey   = null;
            bool   enableHTTPS = false;

            if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
            {
                endPoint  = Environment.GetEnvironmentVariable("SERVER_ENDPOINT");
                accessKey = Environment.GetEnvironmentVariable("ACCESS_KEY");
                secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
                if (Environment.GetEnvironmentVariable("ENABLE_HTTPS") != null)
                {
                    enableHTTPS = Environment.GetEnvironmentVariable("ENABLE_HTTPS").Equals("1");
                }
            }
            else
            {
                endPoint    = "play.min.io:9000";
                accessKey   = "Q3AM3UQ867SPQQA43P2F";
                secretKey   = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
                enableHTTPS = true;
            }
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => true;
            // WithSSL() enables SSL support in MinIO client
            MinioClient minioClient = null;

            if (enableHTTPS)
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey).WithSSL();
            }
            else
            {
                minioClient = new Minio.MinioClient(endPoint, accessKey, secretKey);
            }

            try
            {
                // Assign parameters before starting the test
                string        bucketName     = GetRandomName();
                string        smallFileName  = CreateFile(1 * UNIT_MB);
                string        bigFileName    = CreateFile(6 * UNIT_MB);
                string        objectName     = GetRandomName();
                string        destBucketName = GetRandomName();
                string        destObjectName = GetRandomName();
                List <string> objectsList    = new List <string>();
                for (int i = 0; i < 10; i++)
                {
                    objectsList.Add(objectName + i.ToString());
                }
                // Set app Info
                minioClient.SetAppInfo("app-name", "app-version");

                // Set HTTP Tracing On
                // minioClient.SetTraceOn();

                // Set HTTP Tracing Off
                // minioClient.SetTraceOff();
                // Check if bucket exists
                Cases.BucketExists.Run(minioClient, bucketName).Wait();

                // Create a new bucket
                Cases.MakeBucket.Run(minioClient, bucketName).Wait();

                Cases.MakeBucket.Run(minioClient, destBucketName).Wait();


                // List all the buckets on the server
                Cases.ListBuckets.Run(minioClient).Wait();

                // Put an object to the new bucket
                Cases.PutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Get object metadata
                Cases.StatObject.Run(minioClient, bucketName, objectName).Wait();

                // List the objects in the new bucket
                Cases.ListObjects.Run(minioClient, bucketName);

                // Delete the file and Download the object as file
                Cases.GetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download partial object as file
                Cases.GetPartialObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Server side copyObject
                Cases.CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName).Wait();

                // Server side copyObject with metadata replacement
                Cases.CopyObjectMetadata.Run(minioClient, bucketName, objectName, destBucketName, objectName).Wait();

                // Upload a File with PutObject
                Cases.FPutObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Delete the file and Download the object as file
                Cases.FGetObject.Run(minioClient, bucketName, objectName, smallFileName).Wait();

                // Automatic Multipart Upload with object more than 5Mb
                Cases.PutObject.Run(minioClient, bucketName, objectName, bigFileName).Wait();

                // Specify SSE-C encryption options
                Aes aesEncryption = Aes.Create();
                aesEncryption.KeySize = 256;
                aesEncryption.GenerateKey();
                var ssec = new SSEC(aesEncryption.Key);
                // Specify SSE-C source side encryption for Copy operations
                var sseCpy = new SSECopy(aesEncryption.Key);

                // Uncommment to specify SSE-S3 encryption option
                // var sses3 = new SSES3();

                // Uncommment to specify SSE-KMS encryption option
                // var sseKms = new SSEKMS("kms-key",new Dictionary<string,string>{{ "kms-context", "somevalue"}});

                // Upload encrypted object
                Cases.PutObject.Run(minioClient, bucketName, objectName, smallFileName, sse: ssec).Wait();
                // Copy SSE-C encrypted object to unencrypted object
                Cases.CopyObject.Run(minioClient, bucketName, objectName, destBucketName, objectName, sseSrc: sseCpy, sseDest: ssec).Wait();
                // Download SSE-C encrypted object
                Cases.FGetObject.Run(minioClient, destBucketName, objectName, bigFileName, sse: ssec).Wait();

                // List the incomplete uploads
                Cases.ListIncompleteUploads.Run(minioClient, bucketName);

                // Remove all the incomplete uploads
                Cases.RemoveIncompleteUpload.Run(minioClient, bucketName, objectName).Wait();

                // Set a policy for given bucket
                Cases.SetBucketPolicy.Run(minioClient, bucketName).Wait();
                // Get the policy for given bucket
                Cases.GetBucketPolicy.Run(minioClient, bucketName).Wait();

                // Set bucket notifications
                Cases.SetBucketNotification.Run(minioClient, bucketName).Wait();

                // Get bucket notifications
                Cases.GetBucketNotification.Run(minioClient, bucketName).Wait();

                // Remove all bucket notifications
                Cases.RemoveAllBucketNotifications.Run(minioClient, bucketName).Wait();

                // Get the presigned url for a GET object request
                Cases.PresignedGetObject.Run(minioClient, bucketName, objectName).Wait();

                // Get the presigned POST policy curl url
                Cases.PresignedPostPolicy.Run(minioClient).Wait();

                // Get the presigned url for a PUT object request
                Cases.PresignedPutObject.Run(minioClient, bucketName, objectName).Wait();

                // Delete the list of objects
                Cases.RemoveObjects.Run(minioClient, bucketName, objectsList).Wait();

                // Delete the object
                Cases.RemoveObject.Run(minioClient, bucketName, objectName).Wait();

                // Delete the object
                Cases.RemoveObject.Run(minioClient, destBucketName, objectName).Wait();

                // Tacing request with custom logger
                Cases.CustomRequestLogger.Run(minioClient).Wait();

                // Remove the buckets
                Cases.RemoveBucket.Run(minioClient, bucketName).Wait();
                Cases.RemoveBucket.Run(minioClient, destBucketName).Wait();

                // Remove the binary files created for test
                File.Delete(smallFileName);
                File.Delete(bigFileName);

                Console.ReadLine();
            }
            catch (MinioException ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
 public MediaController(Minio.MinioClient minioClient, IConfiguration configuration)
 {
     this.minioClient = minioClient;
 }