@@ -867,6 +867,57 @@ public function testGetBucketLocationNonExisted()
867867 * TestObject
868868 **********************************/
869869
870+ /*
871+ * put object, 从本地上传文件
872+ * 200
873+ */
874+ public function testPutObjectLocalObject () {
875+ try {
876+ $ key = '你好.txt ' ;
877+ $ body = $ this ->generateRandomString (1024 +1023 );
878+ $ md5 = base64_encode (md5 ($ body , true ));
879+ $ local_test_key = "local_test_file " ;
880+ $ f = fopen ($ local_test_key , "wb " );
881+ fwrite ($ f , $ body );
882+ fclose ($ f );
883+ $ this ->cosClient ->putObject (['Bucket ' => $ this ->bucket ,
884+ 'Key ' => $ key ,
885+ 'Body ' => fopen ($ local_test_key , "rb " )]);
886+ $ rt = $ this ->cosClient ->getObject (['Bucket ' =>$ this ->bucket , 'Key ' =>$ key ]);
887+ $ download_md5 = base64_encode (md5 ($ rt ['Body ' ], true ));
888+ $ this ->assertEquals ($ md5 , $ download_md5 );
889+ } catch (ServiceResponseException $ e ) {
890+ print $ e ;
891+ $ this ->assertFalse (TRUE );
892+ }
893+ }
894+
895+ /*
896+ * upload, 从本地上传
897+ * 200
898+ */
899+ public function testUploadLocalObject () {
900+ try {
901+ $ key = '你好.txt ' ;
902+ $ body = $ this ->generateRandomString (1024 +1023 );
903+ $ md5 = base64_encode (md5 ($ body , true ));
904+ $ local_test_key = "local_test_file " ;
905+ $ f = fopen ($ local_test_key , "wb " );
906+ fwrite ($ f , $ body );
907+ fclose ($ f );
908+ $ this ->cosClient ->upload ($ bucket =$ this ->bucket ,
909+ $ key =$ key ,
910+ $ body =fopen ($ local_test_key , "rb " ),
911+ $ options =['PartSize ' =>1024 * 1024 + 1 ]);
912+ $ rt = $ this ->cosClient ->getObject (['Bucket ' =>$ this ->bucket , 'Key ' =>$ key ]);
913+ $ download_md5 = base64_encode (md5 ($ rt ['Body ' ], true ));
914+ $ this ->assertEquals ($ md5 , $ download_md5 );
915+ } catch (ServiceResponseException $ e ) {
916+ print $ e ;
917+ $ this ->assertFalse (TRUE );
918+ }
919+ }
920+
870921 /*
871922 * put object,请求头部携带服务端加密参数
872923 * 200
0 commit comments