@@ -907,6 +907,52 @@ func (s *CosTestSuite) TestAccelerate() {
907907 assert .Equal (s .T (), opt .Type , res .Type , "GetAccelerate Failed" )
908908}
909909
910+ func (s * CosTestSuite ) TestMultiCopy () {
911+ u := "http://" + kRepBucket + "-" + s .Appid + ".cos." + kRepRegion + ".myqcloud.com"
912+ iu , _ := url .Parse (u )
913+ ib := & cos.BaseURL {BucketURL : iu }
914+ c := cos .NewClient (ib , & http.Client {
915+ Transport : & cos.AuthorizationTransport {
916+ SecretID : os .Getenv ("COS_SECRETID" ),
917+ SecretKey : os .Getenv ("COS_SECRETKEY" ),
918+ },
919+ })
920+
921+ opt := & cos.BucketPutOptions {
922+ XCosACL : "public-read" ,
923+ }
924+
925+ // Notice in intranet the bucket host sometimes has i/o timeout problem
926+ r , err := c .Bucket .Put (context .Background (), opt )
927+ if err != nil && r .StatusCode == 409 {
928+ fmt .Println ("BucketAlreadyOwnedByYou" )
929+ } else if err != nil {
930+ assert .Nil (s .T (), err , "PutBucket Failed" )
931+ }
932+
933+ source := "test/objectMove1" + time .Now ().Format (time .RFC3339 )
934+ expected := "test"
935+ f := strings .NewReader (expected )
936+
937+ r , err = c .Object .Put (context .Background (), source , f , nil )
938+ assert .Nil (s .T (), err , "PutObject Failed" )
939+
940+ time .Sleep (3 * time .Second )
941+ // Copy file
942+ soruceURL := fmt .Sprintf ("%s/%s" , iu .Host , source )
943+ dest := "test/objectMove1" + time .Now ().Format (time .RFC3339 )
944+ _ , _ , err = s .Client .Object .MultiCopy (context .Background (), dest , soruceURL , nil )
945+ assert .Nil (s .T (), err , "MultiCopy Failed" )
946+
947+ // Check content
948+ resp , err := s .Client .Object .Get (context .Background (), dest , nil )
949+ assert .Nil (s .T (), err , "GetObject Failed" )
950+ bs , _ := ioutil .ReadAll (resp .Body )
951+ resp .Body .Close ()
952+ result := string (bs )
953+ assert .Equal (s .T (), expected , result , "MultiCopy Failed, wrong content" )
954+ }
955+
910956// End of api test
911957
912958// All methods that begin with "Test" are run as tests within a
0 commit comments