@@ -67,7 +67,56 @@ public function testPut_sizelimit()
67
67
list ($ ret , $ err ) = Qiniu_Put ($ upToken , $ key , "hello world! " , null );
68
68
$ this ->assertNull ($ ret );
69
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 ' );
70
116
var_dump ($ ret );
117
+
118
+ $ err = Qiniu_RS_Delete ($ this ->client , $ this ->bucket , $ key );
119
+ $ this ->assertNull ($ err );
71
120
}
72
121
}
73
122
0 commit comments