public async Task DeleteAfterDaysTest() { var config = new Config { Zone = Zone.ZoneCnEast }; var mac = new Mac(AccessKey, SecretKey); var bucketManager = new BucketManager(mac, config); var newKey = "qiniu-to-copy.png"; var copyRet = await bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey, true); if (copyRet.Code != (int)HttpCode.OK) { Assert.True(false, "copy error: " + copyRet); } Console.WriteLine(copyRet.ToString()); var expireRet = await bucketManager.DeleteAfterDays(Bucket, newKey, 7); if (expireRet.Code != (int)HttpCode.OK) { Assert.True(false, "deleteAfterDays error: " + expireRet); } Console.WriteLine(expireRet.ToString()); }
public async Task MoveTest() { var config = new Config { Zone = Zone.ZoneCnEast }; var mac = new Mac(AccessKey, SecretKey); var bucketManager = new BucketManager(mac, config); var newKey = "qiniu-to-copy.png"; var copyRet = await bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey, true); if (copyRet.Code != (int)HttpCode.OK) { Assert.True(false, "copy error: " + copyRet); } Console.WriteLine(copyRet.ToString()); var moveRet = await bucketManager.Move(Bucket, newKey, Bucket, "qiniu-move-target.png", true); if (moveRet.Code != (int)HttpCode.OK) { Assert.True(false, "move error: " + moveRet); } Console.WriteLine(moveRet.ToString()); }
public void MoveTest() { 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 newKey = "qiniu-to-copy.png"; HttpResult copyRet = bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey, true); if (copyRet.Code != (int)HttpCode.OK) { Assert.Fail("copy error: " + copyRet.ToString()); } Console.WriteLine(copyRet.ToString()); HttpResult moveRet = bucketManager.Move(Bucket, newKey, Bucket, "qiniu-move-target.png", true); if (moveRet.Code != (int)HttpCode.OK) { Assert.Fail("move error: " + moveRet.ToString()); } Console.WriteLine(moveRet.ToString()); }
public void CopyTest() { Mac mac = new Mac(AccessKey, SecretKey); BucketManager target = new BucketManager(mac); HttpResult result = target.Copy(Bucket1, FileKey1, Bucket2, FileKey2, true); bool cond = (result.Code == (int)HttpCode.OK || result.Code == (int)HttpCode.BUCKET_NOT_EXIST || result.Code == (int)HttpCode.FILE_NOT_EXIST); Assert.IsTrue(cond); }
public async Task DeleteTest() { var config = new Config { Zone = Zone.ZoneCnEast }; var mac = new Mac(AccessKey, SecretKey); var bucketManager = new BucketManager(mac, config); var newKey = "qiniu-to-delete.png"; await bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey); var deleteRet = await bucketManager.Delete(Bucket, newKey); if (deleteRet.Code != (int)HttpCode.OK) { Assert.True(false, "delete error: " + deleteRet); } }
public void DeleteTest() { Config config = new Config(); config.Zone = Zone.ZONE_CN_East; Mac mac = new Mac(AccessKey, SecretKey); BucketManager bucketManager = new BucketManager(mac, config); string newKey = "qiniu-to-delete.png"; bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey); HttpResult deleteRet = bucketManager.Delete(Bucket, newKey); if (deleteRet.Code != (int)HttpCode.OK) { Assert.Fail("delete error: " + deleteRet.ToString()); } }
/// <summary> /// 复制文件 /// </summary> public static void copy() { Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey); string srcBucket = "test"; string srcKey = "1.txt"; string dstBucket = "test"; string dstKey = "2.txt"; BucketManager bm = new BucketManager(mac); var result = bm.Copy(srcBucket, srcKey, dstBucket, dstKey); //支持force参数, bool force = true/false //var result = bm.Copy(srcBucket, srcKey, dstBucket, dstKey, force); Console.WriteLine(result); }
public async Task <string> DeleteFile(string fileKey) { string Msg = "删除成功"; Config config = new Config(); config.Zone = Zone.ZoneCnEast; var mac = SetMac(); BucketManager bucketManager = new BucketManager(mac, config); string newKey = "UploadFileTest_337756368.dat"; await bucketManager.Copy(Bucket, "UploadFileTest_337756368.dat", Bucket, newKey); HttpResult deleteRet = await bucketManager.Delete(Bucket, newKey); if (deleteRet.Code != (int)HttpCode.OK) { Msg = "删除失败"; } return(Msg); }
public void DeleteAfterDaysTest() { Config config = new Config(); config.Zone = Zone.ZONE_CN_East; Mac mac = new Mac(AccessKey, SecretKey); BucketManager bucketManager = new BucketManager(mac, config); string newKey = "qiniu-to-copy.png"; HttpResult copyRet = bucketManager.Copy(Bucket, "qiniu.png", Bucket, newKey, true); if (copyRet.Code != (int)HttpCode.OK) { Assert.Fail("copy error: " + copyRet.ToString()); } Console.WriteLine(copyRet.ToString()); HttpResult expireRet = bucketManager.DeleteAfterDays(Bucket, newKey, 7); if (expireRet.Code != (int)HttpCode.OK) { Assert.Fail("deleteAfterDays error: " + expireRet.ToString()); } Console.WriteLine(expireRet.ToString()); }
static void Main(string[] args) { Auth auth = EnvUtility.EnvAuth(); Config config = EnvUtility.EnvConfig(); BucketManager bm = new BucketManager(auth, config); // 枚举所有 Buckets HttpResult result = bm.Buckets(); Console.WriteLine("---Buckets---\n{0}", result.ToString()); if ((int)HttpStatusCode.OK == result.Code) { JObject jo = JObject.Parse(result.Text); var buckets = jo["buckets"]; Console.WriteLine("{0} Buckets found:", buckets.Count()); int i = 0; foreach (var bucket in buckets) { // 打印 Bucket 名字 Console.WriteLine("{0}\t{1}", ++i, bucket["name"].ToString()); } } // BucketManager 还有很多函数,以下示范比较粗糙,您需要自己改改! result = bm.BucketList("umu618-docs", 0, null, 1); Console.WriteLine("---BucketList---\n{0}", result.ToString()); result = bm.BucketStat("chentemp|umu618-docs", "2017-07-01", "2017-09-01"); Console.WriteLine("---BucketStat---\n{0}", result.ToString()); result = bm.Stat("umu618-docs", "Go.pdf"); Console.WriteLine("---Stat---\n{0}", result.ToString()); string[] keys = { "Go.pdf" }; result = bm.Prefetch("umu618-docs", keys); Console.WriteLine("---Prefetch---\n{0}", result.ToString()); result = bm.ImageInfo("http://images.w.wcsapi.biz.matocloud.com/1.png"); Console.WriteLine("---ImageInfo---\n{0}", result.ToString()); result = bm.Exif("http://chentemp.w.wcsapi.biz.matocloud.com/IMG_1140.JPG"); Console.WriteLine("---Exif---\n{0}", result.ToString()); result = bm.AvInfo("http://images.w.wcsapi.biz.matocloud.com/1.mp4"); Console.WriteLine("---AvInfo---\n{0}", result.ToString()); result = bm.AvInfo2("http://images.w.wcsapi.biz.matocloud.com/1.mp4"); Console.WriteLine("---AvInfo2---\n{0}", result.ToString()); result = bm.Delete("umu618-docs", "/temp/"); Console.WriteLine("---Delete---\n{0}", result.ToString()); result = bm.Move("umu618-docs", "Go.pdf", "umu618-docs", "golang/Go.pdf"); Console.WriteLine("---Move---\n{0}", result.ToString()); result = bm.Copy("umu618-docs", "data.txt", "umu618-docs", "data.txt"); Console.WriteLine("---Copy---\n{0}", result.ToString()); result = bm.Decompression("umu618-docs", "各种录音程序.7z", "7z", "umu618-docs:exe", "umu618-docs:exe/UMU.list"); Console.WriteLine("---Decompression---\n{0}", result.ToString()); Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("umu618-docs:/", "umu618-docs:UMU.list"); d.Add("umu618-docs:temp", "umu618-docs:temp/UMU.list"); result = bm.Decompression("umu618-docs", "各种录音程序.7z", "7z", d); Console.WriteLine("---Decompression---\n{0}", result.ToString()); result = bm.PersistentStatus("e534f75d41534f468a7efe9a51dc90ad"); Console.WriteLine("---PersistentStatus---\n{0}", result.ToString()); result = bm.SetDeadline("umu618-docs", "Go.pdf", -1); Console.WriteLine("---SetDeadline---\n{0}", result.ToString()); }