@@ -55,5 +55,68 @@ public function testPut()
5555 $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
5656 $ this ->assertNull ($ err );
5757 }
58+
59+ public function testPut_sizelimit ()
60+ {
61+ $ key = 'testPut_sizelimit ' . getTid ();
62+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
63+
64+ $ putPolicy = new Qiniu_RS_PutPolicy ($ this ->bucket );
65+ $ putPolicy ->FsizeLimit = 1 ;
66+ $ upToken = $ putPolicy ->Token (null );
67+ list ($ ret , $ err ) = Qiniu_Put ($ upToken , $ key , "hello world! " , null );
68+ $ this ->assertNull ($ ret );
69+ $ this ->assertEquals ($ err ->Err , 'exceed FsizeLimit ' );
70+ var_dump ($ err );
71+ }
72+
73+ public function testPut_mime_save ()
74+ {
75+ $ key = 'testPut_mime_save ' . getTid ();
76+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
77+
78+ $ putPolicy = new Qiniu_RS_PutPolicy ($ this ->bucket );
79+ $ putPolicy ->DetectMime = 1 ;
80+ $ putPolicy ->SaveKey = $ key ;
81+ $ upToken = $ putPolicy ->Token (null );
82+ $ putExtra = new Qiniu_PutExtra ();
83+ $ putExtra ->MimeType = 'image/jpg ' ;
84+ list ($ ret , $ err ) = Qiniu_PutFile ($ upToken , null , __file__, $ putExtra );
85+ $ this ->assertNull ($ err );
86+
87+ list ($ ret , $ err ) = Qiniu_RS_Stat ($ this ->client , $ this ->bucket , $ key );
88+ $ this ->assertNull ($ err );
89+ $ this ->assertEquals ($ ret ['mimeType ' ], 'application/x-httpd-php ' );
90+ var_dump ($ ret );
91+
92+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
93+ $ this ->assertNull ($ err );
94+ }
95+
96+ public function testPut_exclusive ()
97+ {
98+ $ key = 'testPut_exclusive ' . getTid ();
99+ $ scope = $ this ->bucket . ': ' . $ key ;
100+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
101+
102+ $ putPolicy = new Qiniu_RS_PutPolicy ($ scope );
103+ $ putPolicy ->InsertOnly = 1 ;
104+ $ upToken = $ putPolicy ->Token (null );
105+
106+ list ($ ret , $ err ) = Qiniu_Put ($ upToken , $ key , "hello world! " , null );
107+ $ this ->assertNull ($ err );
108+ list ($ ret , $ err ) = Qiniu_PutFile ($ upToken , $ key , __file__, null );
109+ $ this ->assertNull ($ ret );
110+ $ this ->assertEquals ($ err ->Err , 'file exists ' );
111+ var_dump ($ err );
112+
113+ list ($ ret , $ err ) = Qiniu_RS_Stat ($ this ->client , $ this ->bucket , $ key );
114+ $ this ->assertNull ($ err );
115+ $ this ->assertEquals ($ ret ['mimeType ' ], 'application/octet-stream ' );
116+ var_dump ($ ret );
117+
118+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
119+ $ this ->assertNull ($ err );
120+ }
58121}
59122
0 commit comments