@@ -836,18 +836,29 @@ public function testEncodeFilePath()
836
836
$ hexfilePath1 = bin2hex ($ filePath1 );
837
837
$ hexGbkfilePath2 = bin2hex ($ gbkfilePath2 );
838
838
839
- //$this->assertEquals("e4b8ade69687e69687e4bbb6e5908d312e747874", $hexfilePath1);
840
- //$this->assertEquals("d6d0cec4cec4bcfec3fb322e747874", $hexGbkfilePath2);
841
- try {
842
- mkdir ($ fileFolder );
843
- } catch (\Exception $ e ) {
839
+ $ content1 = '' ;
840
+ $ content2 = '' ;
841
+ if (version_compare (phpversion (), '7.0.0 ' , '< ' )) {
842
+ try {
843
+ mkdir ($ gbkfileFolder );
844
+ } catch (\Exception $ e ) {
845
+ }
846
+ OssUtil::generateFile ($ gbkfilePath1 , 200 * 1024 );
847
+ OssUtil::generateFile ($ gbkfilePath2 , 202 * 1024 );
848
+ $ content1 = file_get_contents ($ gbkfilePath1 );
849
+ $ content2 = file_get_contents ($ gbkfilePath2 );
850
+ } else {
851
+ try {
852
+ mkdir ($ fileFolder );
853
+ } catch (\Exception $ e ) {
854
+ }
855
+ OssUtil::generateFile ($ filePath1 , 200 * 1024 );
856
+ OssUtil::generateFile ($ filePath2 , 202 * 1024 );
857
+ $ content1 = file_get_contents ($ filePath1 );
858
+ $ content2 = file_get_contents ($ filePath2 );
844
859
}
845
- OssUtil::generateFile ($ filePath1 , 200 * 1024 );
846
- OssUtil::generateFile ($ filePath2 , 202 * 1024 );
847
860
848
861
try {
849
- $ content1 = file_get_contents ($ filePath1 );
850
- $ content2 = file_get_contents ($ filePath2 );
851
862
852
863
// upload file
853
864
$ this ->ossClient ->uploadFile ($ this ->bucket , '123 ' , $ filePath1 );
@@ -887,6 +898,20 @@ public function testEncodeFilePath()
887
898
$ this ->assertEquals ('dir/中文文件名1.txt ' , $ objectList [0 ]->getKey ());
888
899
$ this ->assertEquals ('dir/中文文件名2.txt ' , $ objectList [1 ]->getKey ());
889
900
901
+ // uploadDir
902
+ if (version_compare (phpversion (), '7.0.0 ' , '< ' )) {
903
+ $ this ->ossClient ->uploadDir ($ this ->bucket , "gbkdir " , $ gbkfileFolder );
904
+ $ options = array (
905
+ 'delimiter ' => '' ,
906
+ 'prefix ' => "gbkdir " ,
907
+ );
908
+ $ listObjectInfo = $ this ->ossClient ->listObjects ($ this ->bucket , $ options );
909
+ $ objectList = $ listObjectInfo ->getObjectList ();
910
+ $ this ->assertEquals (2 , count ($ objectList ));
911
+ $ this ->assertEquals ('gbkdir/中文文件名1.txt ' , $ objectList [0 ]->getKey ());
912
+ $ this ->assertEquals ('gbkdir/中文文件名2.txt ' , $ objectList [1 ]->getKey ());
913
+ }
914
+
890
915
} catch (OssException $ e ) {
891
916
$ this ->assertFalse (true );
892
917
}
0 commit comments