Пример #1
0
        public void clear()
        {
            DeleteObject();
            MultiDeleteObject();

            QCloudServer.DeleteAllFile(localDir, "*.txt");
        }
Пример #2
0
        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();
        }