public void BatchChangeMimeTest() { BatchCopyTest(); Config config = new Config(); config.Zone = Zone.ZONE_CN_East; //config.Region = Region.Region_CN_East; Mac mac = new Mac(AccessKey, SecretKey); BucketManager bucketManager = new BucketManager(mac, config); string[] keys = { "qiniu-0.png", "qiniu-1.png", "qiniu-2.png" }; List <string> ops = new List <string>(); foreach (string key in keys) { string op = bucketManager.ChangeMimeOp(Bucket, key, "image/batch-x-png"); ops.Add(op); } BatchResult ret = bucketManager.Batch(ops); if (ret.Code / 100 != 2) { Assert.Fail("batch error: " + ret.ToString()); } foreach (BatchInfo info in ret.Result) { if (info.Code == (int)HttpCode.OK) { Console.WriteLine("chgm success"); } else { Console.WriteLine(info.Data.Error); } } }
public async Task BatchChangeMimeTest() { await BatchCopyTest(); var config = new Config { Zone = Zone.ZoneCnEast }; var mac = new Mac(AccessKey, SecretKey); var bucketManager = new BucketManager(mac, config); string[] keys = { "qiniu-0.png", "qiniu-1.png", "qiniu-2.png" }; var ops = keys.Select(key => bucketManager.ChangeMimeOp(Bucket, key, "image/batch-x-png")).ToList(); var ret = await bucketManager.Batch(ops); if (ret.Code / 100 != 2) { Assert.True(false, "batch error: " + ret); } foreach (var info in ret.Result) { if (info.Code == (int)HttpCode.OK) { Console.WriteLine("chgm success"); } else { Console.WriteLine(info.Data.Error); } } }