public void ResumablePutFileTest()
        {
            Settings putSetting = new Settings(); // TODO: 初始化为适当的值
            string key=NewKey;
            ResumablePutExtra extra = new ResumablePutExtra();
            extra.Notify += new EventHandler<PutNotifyEvent>(extra_Notify);
            extra.NotifyErr += new EventHandler<PutNotifyErrorEvent>(extra_NotifyErr);
            extra.Bucket = Bucket;
            ResumablePut target = new ResumablePut(putSetting, extra); // TODO: 初始化为适当的值
            Console.WriteLine ("extra.Bucket:"+extra.Bucket);
            string upToken = new PutPolicy(extra.Bucket).Token(new Qiniu.Auth.digest.Mac());
            target.Progress += new Action<float>(target_Progress);
            TmpFIle file=new TmpFIle(1024*1024*4);
            target.PutFinished += new EventHandler<CallRet> ((o,e) => {
                file.Del ();
                if (e.OK) {
                    RSHelper.RSDel (Bucket, key);
                }
            });
            target.PutFile (upToken, file.FileName, key);

            //Action a = new Action (() =>
            //{
            //	target.PutFile (upToken, BigFile, NewKey);
            //});
            //a.BeginInvoke (null,null);
        }
        public void ResumablePutFileTest()
        {
			Settings putSetting = new Settings(); // TODO: 初始化为适当的值
			string key=NewKey;
            ResumablePutExtra extra = new ResumablePutExtra();
			NameValueCollection nc = new NameValueCollection ();
			nc.Add("x:username","qiniu");
			extra.CallbackParams = nc;
            extra.Notify += new EventHandler<PutNotifyEvent>(extra_Notify);
            extra.NotifyErr += new EventHandler<PutNotifyErrorEvent>(extra_NotifyErr);
            ResumablePut target = new ResumablePut(putSetting, extra); // TODO: 初始化为适当的值
			Console.WriteLine ("extra.Bucket:"+Bucket);
            string upToken = new PutPolicy(Bucket).Token(new Qiniu.Auth.digest.Mac());
			TmpFIle file=new TmpFIle(1024*1024*4);
			target.PutFinished += new EventHandler<CallRet> ((o,e) => {
				file.Del ();
				if (e.OK) {
					RSHelper.RSDel (Bucket, key);
				}
			});
			CallRet ret =target.PutFile (upToken, file.FileName, key);

			//Action a = new Action (() =>
			//{
			//	target.PutFile (upToken, BigFile, NewKey);            
			//});
			//a.BeginInvoke (null,null);

		}
Exemple #3
0
        public void PutFileWithoutKeyTest()
        {
            IOClient target = new IOClient();
            string key = NewKey;
            PrintLn (key);
            PutExtra extra = new PutExtra (); // TODO: 初始化为适当的值
            extra.MimeType = "text/plain";
            extra.Crc32 = 123;
            extra.CheckCrc = CheckCrcType.CHECK;
            extra.Params = new System.Collections.Generic.Dictionary<string, string> ();
            PutPolicy put = new PutPolicy (Bucket);
            TmpFIle file = new TmpFIle (1024 * 10);
            target.PutFinished += new EventHandler<PutRet> ((o,e) => {
                file.Del ();
                if (e.OK) {
                    RSHelper.RSDel (Bucket, file.FileName);
                }
            });

            PutRet ret = target.PutFileWithoutKey (put.Token (),file.FileName, extra);

            //error params
            //target.PutFile("error", "error", "error", null);
            Assert.IsTrue (ret.OK, "PutFileTest Failure");
        }