Esempio n. 1
0
        // 使用FormUploader上传数据
        public static void frmUploadData()
        {
            Mac          mac    = new Mac(Settings.AccessKey, Settings.SecretKey);
            FormUploader target = new FormUploader();

            byte[] data = Encoding.UTF8.GetBytes("hello world");
            string key  = "test_FormUploaderUploadData.txt";

            PutPolicy putPolicy = new PutPolicy();

            putPolicy.Scope = Settings.Bucket;
            putPolicy.SetExpires(3600);
            putPolicy.DeleteAfterDays = 1;
            string token = Auth.createUploadToken(putPolicy, mac);

            Console.WriteLine(key);
            Console.WriteLine(putPolicy);
            Console.WriteLine(token);

            target.uploadData(data, key, token, null, null);

            Console.WriteLine();
        }
Esempio n. 2
0
        public void uploadDataTest()
        {
            //Settings.load();
            Settings.LoadFromFile("F:\\test.cfg");
            Mac          mac    = new Mac(Settings.AccessKey, Settings.SecretKey);
            FormUploader target = new FormUploader();

            byte[] data = Encoding.UTF8.GetBytes("hello world");
            string key  = "test_FormUploaderUploadData.txt";

            PutPolicy putPolicy = new PutPolicy();

            putPolicy.Scope = Settings.Bucket;
            putPolicy.SetExpires(3600);
            putPolicy.DeleteAfterDays = 1;
            string              token               = Auth.createUploadToken(putPolicy, mac);
            UploadOptions       uploadOptions       = null;
            UpCompletionHandler upCompletionHandler = new UpCompletionHandler(delegate(string fileKey, ResponseInfo respInfo, string response)
            {
                Assert.AreEqual(200, respInfo.StatusCode);
            });

            target.uploadData(data, key, token, uploadOptions, upCompletionHandler);
        }