@@ -16,7 +16,15 @@ public void UploadFileTest()
1616 Random rand = new Random ( ) ;
1717 string key = string . Format ( "UploadFileTest_{0}.dat" , rand . Next ( ) ) ;
1818
19- string filePath = LocalFile ;
19+ string tempPath = System . IO . Path . GetTempPath ( ) ;
20+ int rnd = new Random ( ) . Next ( 1 , 100000 ) ;
21+ string filePath = tempPath + "resumeFile" + rnd . ToString ( ) ;
22+ char [ ] testBody = new char [ 4 * 1024 * 1024 ] ;
23+ System . IO . FileStream stream = new System . IO . FileStream ( filePath , System . IO . FileMode . Create ) ;
24+ System . IO . StreamWriter sw = new System . IO . StreamWriter ( stream , System . Text . Encoding . Default ) ;
25+ sw . Write ( testBody ) ;
26+ sw . Close ( ) ;
27+ stream . Close ( ) ;
2028
2129 PutPolicy putPolicy = new PutPolicy ( ) ;
2230 putPolicy . Scope = Bucket + ":" + key ;
@@ -33,6 +41,7 @@ public void UploadFileTest()
3341 HttpResult result = target . UploadFile ( filePath , key , token , null ) ;
3442 Console . WriteLine ( "chunk upload result: " + result . ToString ( ) ) ;
3543 Assert . AreEqual ( ( int ) HttpCode . OK , result . Code ) ;
44+ System . IO . File . Delete ( filePath ) ;
3645 }
3746
3847 [ Test ]
@@ -41,8 +50,16 @@ public void ResumeUploadFileTest()
4150 Mac mac = new Mac ( AccessKey , SecretKey ) ;
4251 Random rand = new Random ( ) ;
4352 string key = string . Format ( "UploadFileTest_{0}.dat" , rand . Next ( ) ) ;
44-
45- string filePath = LocalFile ;
53+
54+ string tempPath = System . IO . Path . GetTempPath ( ) ;
55+ int rnd = new Random ( ) . Next ( 1 , 100000 ) ;
56+ string filePath = tempPath + "resumeFile" + rnd . ToString ( ) ;
57+ char [ ] testBody = new char [ 4 * 1024 * 1024 ] ;
58+ System . IO . FileStream stream = new System . IO . FileStream ( filePath , System . IO . FileMode . Create ) ;
59+ System . IO . StreamWriter sw = new System . IO . StreamWriter ( stream , System . Text . Encoding . Default ) ;
60+ sw . Write ( testBody ) ;
61+ sw . Close ( ) ;
62+ stream . Close ( ) ;
4663 System . IO . Stream fs = System . IO . File . OpenRead ( filePath ) ;
4764
4865 PutPolicy putPolicy = new PutPolicy ( ) ;
@@ -65,6 +82,7 @@ public void ResumeUploadFileTest()
6582 HttpResult result = target . UploadStream ( fs , key , token , extra ) ;
6683 Console . WriteLine ( "resume upload: " + result . ToString ( ) ) ;
6784 Assert . AreEqual ( ( int ) HttpCode . OK , result . Code ) ;
85+ System . IO . File . Delete ( filePath ) ;
6886 }
6987 }
7088}
0 commit comments