public void qcstorGetObject()
        {
            EvnContext evn        = EvnContext.loadFromFile(System.Environment.CurrentDirectory + "/tmp/test_key.csv");
            String     bucketName = "java-bucket";
            Bucket     ss         = new Bucket(evn, bucketName);
            String     objectName = "2.txt";

            Bucket.GetObjectInput bb = new Bucket.GetObjectInput();

            //bb.setIfMatch("cda0a741aac6541c730ed6be6c6f5bcc");
            Bucket.GetObjectOutput dd = ss.getObject(objectName, bb);
            Console.WriteLine(dd + "");

            if (dd != null && dd.getBodyInputStream() != null)
            {
                FileStream   ff = new FileStream("D:\\5.txt", FileMode.OpenOrCreate);
                StreamWriter os = new StreamWriter(ff);
                string       buffer;
                while ((buffer = dd.getBodyInputStream().ReadLine()) != null)
                {
                    os.WriteLine(buffer);
                }
                os.Flush();
                os.Close();
                ff.Close();
                dd.getBodyInputStream().Close();
            }
        }
        public void testConfig()
        {
            String config =
                "access_key: 'testkey'\n"
                + "access_secret: 'test_asss'\n"
                + "host: qingcloud.com\n"
                + "port: 443\n"
                + "protocol: https\n";
            FileStream f     = new FileStream(System.Environment.CurrentDirectory + "/tmp/key.csv", FileMode.Open);
            Boolean    bConf = false;

            try
            {
                StreamReader output = new StreamReader(f);
                output.ReadToEnd();
                output.Close();
                f.Close();
                bConf = true;
            }
            catch (Exception e)
            {
                System.Console.Write(e.Message);
            }

            if (bConf)
            {
                EvnContext evnContext = EvnContext.loadFromFile(System.Environment.CurrentDirectory + "/tmp/key.csv");
                Assert.AreEqual(evnContext.getAccessKey(), "testkey");
                Assert.AreEqual(evnContext.getAccessSecret(), "testaccess");
                Assert.AreEqual(evnContext.getRequestUrl(), "https://qingcloud.com:443");
            }
        }
        public void qcstorDeleteBucketObject()
        {
            EvnContext evn        = EvnContext.loadFromFile(System.Environment.CurrentDirectory + "/tmp/test_key.csv");
            String     bucketName = "java-bucket";
            Bucket     ss         = new Bucket(evn, bucketName);
            String     objectName = "2.txt";


            //bb.setIfMatch("cda0a741aac6541c730ed6be6c6f5bcc");
            OutputModel dd = ss.deleteObject(objectName);

            Console.WriteLine(dd + "");
        }
예제 #4
0
 public static EvnContext getEvnContext()
 {
     return(EvnContext.loadFromFile(System.Environment.CurrentDirectory + "/tmp/test_key.csv"));
 }