public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient      = OssClientFactory.CreateOssClient();
            _ossPayerClient = new OssClient(Config.Endpoint, Config.PayerAccessKeyId, Config.PayerAccessKeySecret);

            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);

            string policy = "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:*\"],\"Effect\": \"Allow\"," +
                            "\"Principal\":[\"" + Config.PayerUid + "\"]," +
                            "\"Resource\": [\"acs:oss:*:*:" + _bucketName + "\",\"acs:oss:*:*:" + _bucketName + "/*\"]}]}";

            _ossClient.SetBucketPolicy(new SetBucketPolicyRequest(_bucketName, policy));
            _ossClient.SetBucketRequestPayment(new SetBucketRequestPaymentRequest(_bucketName, RequestPayer.Requester));


            _archiveBucketName = _bucketName + "archive";
            _ossClient.CreateBucket(_bucketName);
            _ossClient.CreateBucket(_archiveBucketName, StorageClass.Archive);
            policy = "{\"Version\":\"1\",\"Statement\":[{\"Action\":[\"oss:*\"],\"Effect\": \"Allow\"," +
                     "\"Principal\":[\"" + Config.PayerUid + "\"]," +
                     "\"Resource\": [\"acs:oss:*:*:" + _archiveBucketName + "\",\"acs:oss:*:*:" + _archiveBucketName + "/*\"]}]}";
            _ossClient.SetBucketPolicy(new SetBucketPolicyRequest(_archiveBucketName, policy));
            _ossClient.SetBucketRequestPayment(new SetBucketRequestPaymentRequest(_archiveBucketName, RequestPayer.Requester));
        }
Beispiel #2
0
 public static void ClassInitialize()
 {
     //get a OSS client object
     _ossClient = OssClientFactory.CreateOssClient();
     //create the bucket
     _bucketName  = OssTestUtils.GetBucketName("bucket-inventory");
     _bucketName2 = _bucketName + "-dest";
     _ossClient.CreateBucket(_bucketName);
     _ossClient.CreateBucket(_bucketName2);
 }
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);

            //upload sample object as source object
            _sourceObjectKey = OssTestUtils.GetObjectKey(_className);
            var metadata = new ObjectMetadata();
            var poResult = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceObjectKey, 
                Config.UploadSampleFile, metadata);
            _sourceObjectETag = poResult.ETag;

            //upload multipart sample object as source object
            _sourceBigObjectKey = _sourceObjectKey + ".js";
            metadata = new ObjectMetadata();
            poResult = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceBigObjectKey,
                Config.MultiUploadSampleFile, metadata);
            _sourceBigObjectETag = poResult.ETag;
        }
Beispiel #4
0
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);

            //upload sample object as source object
            _sourceObjectKey = OssTestUtils.GetObjectKey(_className);
            var metadata = new ObjectMetadata();
            var poResult = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceObjectKey,
                                                     Config.UploadSampleFile, metadata);

            _sourceObjectETag = poResult.ETag;

            //upload multipart sample object as source object
            _sourceBigObjectKey = _sourceObjectKey + ".js";
            metadata            = new ObjectMetadata();
            poResult            = OssTestUtils.UploadObject(_ossClient, _bucketName, _sourceBigObjectKey,
                                                            Config.MultiUploadSampleFile, metadata);
            _sourceBigObjectETag = poResult.ETag;
        }
 public static void EnsureBucketExist(IOss oss, string bucketName)
 {
     if (!BucketExists(oss, bucketName))
     {
         oss.CreateBucket(bucketName);
     }
 }
Beispiel #6
0
 public static void ClassInitialize()
 {
     //get current class name, which is prefix of bucket/object
     _className  = TestContext.CurrentContext.Test.FullName;
     _className  = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
     _ossClient  = OssClientFactory.CreateOssClient();
     _bucketName = OssTestUtils.GetBucketName(_className);
     _ossClient.CreateBucket(_bucketName);
 }
 public static void ClassInitialize()
 {
     //get a OSS client object
     _ossClient = OssClientFactory.CreateOssClient();
     _className = TestContext.CurrentContext.Test.FullName;
     _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
     //create the bucket
     _bucketName = OssTestUtils.GetBucketName(_className);
     _ossClient.CreateBucket(_bucketName);
 }
 public static void ClassInitialize()
 {
     //get a OSS client object
     _ossClient = OssClientFactory.CreateOssClient();
     //get current class name, which is prefix of bucket/object
     _className = TestContext.CurrentContext.Test.FullName;
     _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
     //create the bucket
     _bucketName = OssTestUtils.GetBucketName(_className);
     _ossClient.CreateBucket(_bucketName);
 }
Beispiel #9
0
        public void CreateAndDeleteBucketTest()
        {
            //get a random bucketName
            var bucketName = OssTestUtils.GetBucketName(_className);

            //assert bucket does not exist
            Assert.IsFalse(OssTestUtils.BucketExists(_ossClient, bucketName),
                           string.Format("Bucket {0} should not exist before creation", bucketName));

            //create a new bucket
            _ossClient.CreateBucket(bucketName);
            OssTestUtils.WaitForCacheExpire();
            Assert.IsTrue(OssTestUtils.BucketExists(_ossClient, bucketName),
                          string.Format("Bucket {0} should exist after creation", bucketName));

            //delete the new created bucket
            _ossClient.DeleteBucket(bucketName);
            OssTestUtils.WaitForCacheExpire();
            Assert.IsFalse(OssTestUtils.BucketExists(_ossClient, bucketName),
                           string.Format("Bucket {0} should not exist after deletion", bucketName));
        }
        public static void ClassInitialize()
        {
            _config = new ClientConfiguration();

            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient(_config);
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);
            //create sample object
            _objectKey = OssTestUtils.GetObjectKey(_className);
            OssTestUtils.UploadObject(_ossClient, _bucketName, _objectKey,
                                      Config.UploadTestFile, new ObjectMetadata());
        }
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);

            //upload sample object
            _objectKey = OssTestUtils.GetObjectKey(_className);
            //upload multipart sample object
            _bigObjectKey = _objectKey + ".js";

            // temporary local file
            _tmpLocalFile = _className + ".tmp";
        }
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);
            //create sample object
            _keyName = OssTestUtils.GetObjectKey(_className);
            _keyName += ".jpg";

            _process = "image/resize,m_fixed,w_100,h_100";
            _localImageFile = "../../example.jpg";
            _processedKey = "process/image" + _keyName;
            _imageInfo = "{\n    \"FileSize\": {\"value\": \"3587\"},\n    \"Format\": {\"value\": \"jpg\"},\n    \"ImageHeight\": {\"value\": \"100\"},\n    \"ImageWidth\": {\"value\": \"100\"}}";
        }
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);
            //create sample object
            _keyName  = OssTestUtils.GetObjectKey(_className);
            _keyName += ".jpg";

            _process        = "image/resize,m_fixed,w_100,h_100";
            _localImageFile = Config.ImageTestFile;
            _processedKey   = "process/image" + _keyName;
            _imageInfo      = "{\n    \"FileSize\": {\"value\": \"5470\"},\n    \"Format\": {\"value\": \"jpg\"},\n    \"ImageHeight\": {\"value\": \"100\"},\n    \"ImageWidth\": {\"value\": \"100\"},\n    \"ResolutionUnit\": {\"value\": \"1\"},\n    \"XResolution\": {\"value\": \"1/1\"},\n    \"YResolution\": {\"value\": \"1/1\"}}";
        }
Beispiel #14
0
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);
            //create sample object
            _keyName    = OssTestUtils.GetObjectKey(_className);
            _sqlMessage = "name,school,company,age\r\n" +
                          "Lora Francis,School A,Staples Inc,27\r\n" +
                          "Eleanor Little,School B,\"Conectiv, Inc\",43\r\n" +
                          "Rosie Hughes,School C,Western Gas Resources Inc,44\r\n" +
                          "Lawrence Ross,School D,MetLife Inc.,24";

            _jsonMessage = "{\n" +
                           "\t\"name\": \"Lora Francis\",\n" +
                           "\t\"age\": 27,\n" +
                           "\t\"company\": \"Staples Inc\"\n" +
                           "}\n" +
                           "{\n" +
                           "\t\"name\": \"Eleanor Little\",\n" +
                           "\t\"age\": 43,\n" +
                           "\t\"company\": \"Conectiv, Inc\"\n" +
                           "}\n" +
                           "{\n" +
                           "\t\"name\": \"Rosie Hughes\",\n" +
                           "\t\"age\": 44,\n" +
                           "\t\"company\": \"Western Gas Resources Inc\"\n" +
                           "}\n" +
                           "{\n" +
                           "\t\"name\": \"Lawrence Ross\",\n" +
                           "\t\"age\": 24,\n" +
                           "\t\"company\": \"MetLife Inc.\"\n" +
                           "}";

            _test_csv_file      = Path.Combine(Config.DownloadFolder, "sample_data.csv");
            _test_csv_gzip_file = Path.Combine(Config.DownloadFolder, "sample_data.csv.gz");
        }
Beispiel #15
0
        public static void ClassInitialize()
        {
            //get a OSS client object
            _ossClient = OssClientFactory.CreateOssClient();
            //get current class name, which is prefix of bucket/object
            _className = TestContext.CurrentContext.Test.FullName;
            _className = _className.Substring(_className.LastIndexOf('.') + 1).ToLowerInvariant();
            //create the bucket
            _bucketName = OssTestUtils.GetBucketName(_className);
            _ossClient.CreateBucket(_bucketName);

            //upload sample object
            _objectKey = OssTestUtils.GetObjectKey(_className);
            //upload multipart sample object
            _bigObjectKey = _objectKey + ".js";

            // call paramters
            _callbackUrl        = Config.CallbackServer;
            _callbackBody       = "bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&my_var1=${x:var1}";
            _callbackOkResponse = "{\"Status\":\"OK\"}";
        }
Beispiel #16
0
        protected virtual async Task CreateBucketIfNotExists(IOss ossClient, BlobProviderArgs args, IList <string> refererList = null)
        {
            if (!await BucketExistsAsync(ossClient, args))
            {
                var bucketName = GetBucketName(args);

                var request = new CreateBucketRequest(bucketName)
                {
                    //设置存储空间访问权限ACL。
                    ACL = CannedAccessControlList.PublicReadWrite,
                    //设置数据容灾类型。
                    DataRedundancyType = DataRedundancyType.ZRS
                };

                ossClient.CreateBucket(request);

                if (refererList != null && refererList.Count > 0)
                {
                    var srq = new SetBucketRefererRequest(bucketName, refererList);
                    ossClient.SetBucketReferer(srq);
                }
            }
        }
 public static void EnsureBucketExist(IOss oss, string bucketName)
 {
     if (!BucketExists(oss, bucketName))
     {
         oss.CreateBucket(bucketName);
     }
 }
 public static Task <Bucket> CreateBucketAsync(this IOss client, string bucketName)
 {
     return(Task.Factory.StartNew(() => client.CreateBucket(bucketName)));
 }