public void init() { string region = "ap-guangzhou"; CosXmlConfig config = new CosXmlConfig.Builder() .SetRegion(region) .SetDebugLog(true) .SetConnectionLimit(512) .Build(); QCloudCredentialProvider qCloudCredentialProvider = new DefaultSessionQCloudCredentialProvider( "AKIDLT2qvPSOSRq5eM2TR11daHYBfT1rl8fuWgAJhtbo3eFwcbpFnZHAYkgpaFrzvtq4", "i19oUWRIvvpqGpiUgwqa3wufzSbDPyaxv0JYArSQFMc=", 1597907089, "YiPWtzGhVPG5HQlOLQdxZrxHOitu1JXL903fda3a64f28616997f861116b2d7d1EyG_RmvCKqArCLtOXxKv9MGtugt4lPcUbESOTHdhmhEyMYgnPpJSLpbQoKPYzg7WwwvjjXqOKQvs_I9iCHyaBXJu_LToqeuQfO4NFpos8I_NWBKxg23xFpvuXHXJ7kDuyudwu7qInonvJpoXAnb_J-7rMY94aVWSg6kolryvO-x5_C3cBa1fIiKTrwkRP4keh0g3_asIwP99DA-WASJ147C_NsZl9fdTlWEBnIeQqB7uRHAZkF-_f03-fBYJofeYGe7FArrfai4_AO57QbTwacfzHk2s-43WuCIhoLud_-k" ); cosXml = new CosXmlServer(config, qCloudCredentialProvider); transferManager = new TransferManager(cosXml, new TransferConfig()); smallFileSrcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 1); bigFileSrcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 10); FileInfo fileInfo = new FileInfo(smallFileSrcPath); DirectoryInfo directoryInfo = fileInfo.Directory; localDir = directoryInfo.FullName; localFileName = "local.txt"; }
public void Setup() { notExistBucket = "not-exist-bucket-suwjsdjwujehdfkd-" + QCloudServer.Instance().appid; cosXml = QCloudServer.Instance().cosXml; var config = new TransferConfig(); config.DivisionForUpload = 1 * 1024 * 1024; config.DdivisionForCopy = 1 * 1024 * 1024; config.SliceSizeForCopy = 1 * 1024 * 1024; config.SliceSizeForUpload = 1 * 1024 * 1024; transferManager = new TransferManager(cosXml, config); localFilePath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.Seconds) + ".txt", 1024 * 1024 * 1); }
public void Setup() { bucket = QCloudServer.Instance().bucketForObjectTest; photoKey = "example_photo.jpg"; localTempPhotoFilePath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.Seconds) + ".jpg", 1); FileInfo fileInfo = new FileInfo(localTempPhotoFilePath); DirectoryInfo directoryInfo = fileInfo.Directory; GetObjectRequest request = new GetObjectRequest(bucket, photoKey, directoryInfo.FullName, fileInfo.Name); QCloudServer.Instance().cosXml.GetObject(request); }
public void init() { cosXml = QCloudServer.Instance().cosXml; bucket = QCloudServer.Instance().bucketForObjectTest; transferManager = new TransferManager(cosXml, new TransferConfig()); smallFileSrcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 1); bigFileSrcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 10); FileInfo fileInfo = new FileInfo(smallFileSrcPath); DirectoryInfo directoryInfo = fileInfo.Directory; localDir = directoryInfo.FullName; localFileName = "local.txt"; commonKey = "simpleObject" + TimeUtils.GetCurrentTime(TimeUnit.SECONDS); multiKey = "bigObject" + TimeUtils.GetCurrentTime(TimeUnit.SECONDS); copykey = commonKey; imageKey = commonKey; PutObject(); }
public void testObject() { QCloudServer instance = QCloudServer.Instance(); string key = "objecttest.txt"; string srcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 1); FileInfo fileInfo = new FileInfo(srcPath); DirectoryInfo directoryInfo = fileInfo.Directory; QCloudServer.DeleteAllFile(directoryInfo.FullName, "*.txt"); Console.WriteLine(srcPath); srcPath = QCloudServer.CreateFile(TimeUtils.GetCurrentTime(TimeUnit.SECONDS) + ".txt", 1024 * 1024 * 1); fileInfo = new FileInfo(srcPath); directoryInfo = fileInfo.Directory; PutObject(instance.cosXml, instance.bucketForObjectTest, key, @srcPath); PutObjectWithAES256(instance.cosXml, instance.bucketForObjectTest, "aes256_" + key, @srcPath); PutObjectWithCustomerKey(instance.cosXml, instance.bucketForObjectTest, "customerKey_" + key, @srcPath); PutObjectWithKMS(instance.cosXml, instance.bucketForObjectTest, "KMS" + key, @srcPath); HeadObject(instance.cosXml, instance.bucketForObjectTest, key); PutObjectACL(instance.cosXml, instance.bucketForObjectTest, key); GetObjectACL(instance.cosXml, instance.bucketForObjectTest, key); OptionObject(instance.cosXml, instance.bucketForObjectTest, key); string localDir = directoryInfo.FullName; Console.WriteLine(localDir); GetObject(instance.cosXml, instance.bucketForObjectTest, key, localDir, "download.txt"); QCloudServer.DeleteFile(localDir + Path.DirectorySeparatorChar + "download.txt"); DeleteObject(instance.cosXml, instance.bucketForObjectTest, key); key = "multiObjecttest.txt"; MultiUpload(instance.cosXml, instance.bucketForObjectTest, key, srcPath); AbortMultiUpload(instance.cosXml, instance.bucketForObjectTest, key, srcPath); string sourceAppid = instance.appid; string sourceBucket = instance.bucketForObjectTest; string sourceRegion = instance.region; string sourceKey = key; CopySourceStruct copySource = new CopySourceStruct(sourceAppid, sourceBucket, sourceRegion, sourceKey); key = "copy_" + key; CopyObject(instance.cosXml, instance.bucketForObjectTest, key, copySource); DeleteObject(instance.cosXml, instance.bucketForObjectTest, key); key = "multi_" + key; PartCopyObject(instance.cosXml, instance.bucketForObjectTest, key, copySource); DeleteObject(instance.cosXml, instance.bucketForObjectTest, key); key = "post_" + key; PostObject(instance.cosXml, instance.bucketForObjectTest, key, srcPath, null); List <string> keys = new List <string>(); keys.Add(key); MultiDeleteObject(instance.cosXml, instance.bucketForObjectTest, keys); QCloudServer.DeleteFile(srcPath); Assert.Pass(); //manualResetEvent = new ManualResetEvent(false); //key = "objecttest.txt"; //AsynPutObject(instance.cosXml, instance.bucketForObjectTest, key, @srcPath); //manualResetEvent.WaitOne(); //AsynHeadObject(instance.cosXml, instance.bucketForObjectTest, key); //manualResetEvent.WaitOne(); //AsynPutObjectACL(instance.cosXml, instance.bucketForObjectTest, key); //manualResetEvent.WaitOne(); //AsynGetObjectACL(instance.cosXml, instance.bucketForObjectTest, key); //manualResetEvent.WaitOne(); //AsynOptionObject(instance.cosXml, instance.bucketForObjectTest, key); //manualResetEvent.WaitOne(); //AsynDeleteObject(instance.cosXml, instance.bucketForObjectTest, key); //manualResetEvent.WaitOne(); //key = "post_" + key; //AsynPostObject(instance.cosXml, instance.bucketForObjectTest, key, srcPath, null); //manualResetEvent.WaitOne(); //keys = new List<string>(); //keys.Add(key); //AsyncMultiDeleteObject(instance.cosXml, instance.bucketForObjectTest, keys); //manualResetEvent.WaitOne(); }