コード例 #1
0
        /// 实现 Object 跨域访问配置的预请求
        public void OptionObject()
        {
            //.cssg-snippet-body-start:[option-object]
            try
            {
                string bucket               = "examplebucket-1250000000"; //存储桶,格式:BucketName-APPID
                string key                  = "exampleobject";            //对象键
                string origin               = "http://cloud.tencent.com";
                string accessMthod          = "PUT";
                OptionObjectRequest request = new OptionObjectRequest(bucket, key, origin, accessMthod);
                //执行请求
                OptionObjectResult result = cosXml.OptionObject(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
        }