예제 #1
0
        public static bool setBucketLogging()
        {
            try
            {
                Console.WriteLine("--- setBucketLogging: ---");
                Console.WriteLine("Bucket Name: " + bucketName);
                PutBucketLoggingRequest putBucketLoggingRequest = new PutBucketLoggingRequest();
                putBucketLoggingRequest.BucketName = bucketName;
                GetBucketLoggingResult bucketLogging = new GetBucketLoggingResult();
                //bucketLogging.Enable = true;
                //bucketLogging.TargetBucket = "test1-zzy-jr";
                //bucketLogging.TargetPrefix = "test";

                /*BucketLogging.Enable 为false 则为关闭日志设置*/
                putBucketLoggingRequest.BucketLogging = bucketLogging;

                ks3Client.setBucketLogging(putBucketLoggingRequest);

                Console.WriteLine("Success.");
                Console.WriteLine("----------------------\n");
            }
            catch (System.Exception e)
            {
                Console.WriteLine("setBucketLogging Fail! " + e.ToString());
                return(false);
            }
            return(true);
        }
예제 #2
0
 /// 开启存储桶日志服务
 public void PutBucketLogging()
 {
     //.cssg-snippet-body-start:[put-bucket-logging]
     try
     {
         string bucket = "examplebucket-1250000000"; //格式:BucketName-APPID
         PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);
         // 设置保存日志的目标路径
         request.SetTarget("targetbucket-1250000000", "logs/");
         //执行请求
         PutBucketLoggingResult result = cosXml.putBucketLogging(request);
         //请求成功
         Console.WriteLine(result.GetResultInfo());
     }
     catch (COSXML.CosException.CosClientException clientEx)
     {
         //请求失败
         Console.WriteLine("CosClientException: " + clientEx);
     }
     catch (COSXML.CosException.CosServerException serverEx)
     {
         //请求失败
         Console.WriteLine("CosServerException: " + serverEx.GetInfo());
     }
     //.cssg-snippet-body-end
 }
예제 #3
0
        private static async Task EnableDisableLoggingAsync()
        {
            var loggingConfig = new S3BucketLoggingConfig
            {
                TargetBucketName = targetBucketName,
                TargetPrefix     = logObjectKeyPrefix
            };

            // Send request.
            var putBucketLoggingRequest = new PutBucketLoggingRequest
            {
                BucketName    = bucketName,
                LoggingConfig = loggingConfig
            };
            await client.PutBucketLoggingAsync(putBucketLoggingRequest);
        }
예제 #4
0
파일: UnitTestKs3.cs 프로젝트: jflzbest/C-
        public void TestSetBucketLogging()
        {
            if (init())
            {
                PutBucketLoggingRequest putBucketLoggingRequest = new PutBucketLoggingRequest();
                putBucketLoggingRequest.BucketName = bucketName;
                GetBucketLoggingResult bucketLogging = new GetBucketLoggingResult();
                //bucketLogging.Enable = true;
                //bucketLogging.TargetBucket = "test1-zzy-jr";
                //bucketLogging.TargetPrefix = "test";

                /*BucketLogging.Enable 为false 则为关闭日志设置*/
                putBucketLoggingRequest.BucketLogging = bucketLogging;

                ks3Client.setBucketLogging(putBucketLoggingRequest);
            }
        }
예제 #5
0
        public void TestBucketLogging()
        {
            try
            {
                PutBucketLoggingRequest request = new PutBucketLoggingRequest(bucket);

                request.SetTarget("bucket-cssg-source-1253653367", "/abc");
                PutBucketLoggingResult putResult = cosXml.PutBucketLogging(request);

                Assert.IsTrue(putResult.httpCode == 200);

                GetBucketLoggingResult getResult = cosXml.GetBucketLogging(new GetBucketLoggingRequest(bucket));
                Assert.AreEqual(getResult.httpCode, 200);

                // Console.WriteLine(getResult.GetResultInfo());
                Assert.IsNotEmpty((getResult.GetResultInfo()));
                Assert.IsNotEmpty(getResult.RawContentBodyString);

                BucketLoggingStatus status = getResult.bucketLoggingStatus;

                Assert.NotNull(status);
                Assert.NotNull(status.loggingEnabled);
                Assert.NotNull(status.GetInfo());

                string targetBucket = status.loggingEnabled.targetBucket;
                string targetPrefix = status.loggingEnabled.targetPrefix;
                Assert.NotNull(targetBucket);
                Assert.NotNull(targetPrefix);
            }
            catch (COSXML.CosException.CosClientException clientEx)
            {
                Console.WriteLine("CosClientException: " + clientEx.Message);
                Assert.Fail();
            }
            catch (COSXML.CosException.CosServerException serverEx)
            {
                Console.WriteLine("CosServerException: " + serverEx.GetInfo());

                if (serverEx.statusCode != 409 && serverEx.statusCode != 451)
                {
                    Assert.Fail();
                }
            }
        }
        /// <summary>
        /// This method enables logging for an Amazon S3 bucket. Logs will be stored
        /// in the bucket you selected for logging. Each the logObjectKeyPrefix
        /// will be prepended to each log oject.
        /// </summary>
        /// <param name="client">The initialized Amazon S3 client which will be used
        /// to configure and apply logging to the selected Amazon S3 bucket.</param>
        /// <param name="bucketName">The name of the Amazon S3 bucket for which you
        /// wish to enable logging.</param>
        /// <param name="logBucketName">The name of the Amazon S3 bucket where logging
        /// information will be stored.</param>
        /// <param name="logObjectKeyPrefix">The prefix to prepend to each
        /// object key</param>
        public static async Task EnableLoggingAsync(
            IAmazonS3 client,
            string bucketName,
            string logBucketName,
            string logObjectKeyPrefix)
        {
            var loggingConfig = new S3BucketLoggingConfig
            {
                TargetBucketName = logBucketName,
                TargetPrefix     = logObjectKeyPrefix,
            };

            var putBucketLoggingRequest = new PutBucketLoggingRequest
            {
                BucketName    = bucketName,
                LoggingConfig = loggingConfig,
            };
            await client.PutBucketLoggingAsync(putBucketLoggingRequest);
        }
예제 #7
0
 public void PutBucketLoggingAsync(PutBucketLoggingRequest request, OnSuccessCallback <CosResult> successCallback, OnFailedCallback failCallback)
 {
     Schedue(request, new Model.Bucket.PutBucketLoggingResult(), successCallback, failCallback);
 }
예제 #8
0
 public PutBucketLoggingResult PutBucketLogging(PutBucketLoggingRequest request)
 {
     return((Model.Bucket.PutBucketLoggingResult)Excute(request, new Model.Bucket.PutBucketLoggingResult()));
 }
예제 #9
0
 public Task <PutBucketLoggingResponse> PutBucketLoggingAsync(PutBucketLoggingRequest request, CancellationToken cancellationToken = default)
 {
     throw new NotImplementedException();
 }
 public PutBucketLoggingResponse PutBucketLogging(PutBucketLoggingRequest request)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public void PutBucketLoggingAsync(PutBucketLoggingRequest request, AmazonServiceCallback <PutBucketLoggingRequest, PutBucketLoggingResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }