@@ -187,6 +187,30 @@ public function move($from_bucket, $from_key, $to_bucket, $to_key, $force = fals
187187 return $ error ;
188188 }
189189
190+ /**
191+ * 将资源从一个空间到另一个空间
192+ *
193+ * @param $reqBody 待操作资源所在空间
194+ * @param $from_key 待操作资源文件名
195+ * @param $to_bucket 目标资源空间名
196+ * @param $to_key 目标资源文件名
197+ *
198+ * @return mixed 成功返回NULL,失败返回对象Qiniu\Http\Error
199+ * @link https://developer.qiniu.com/dora/manual/4258/video-pulp
200+ */
201+ public function pulpVideo ($ reqBody , $ ops , $ vid , $ params = null )
202+ {
203+ $ path = '/v1/video/ ' . $ vid ;
204+ $ req = array ();
205+ $ req ['data ' ] = $ reqBody ;
206+ $ req ['ops ' ] = $ ops ;
207+ if (isset ($ params )) {
208+ $ req ['params ' ] = $ params ;
209+ }
210+ $ body = json_encode ($ req );
211+ return $ this ->arPost ($ path , $ body );
212+ }
213+
190214 /**
191215 * 主动修改指定资源的文件类型
192216 *
@@ -359,6 +383,15 @@ private function getRsHost()
359383 return $ scheme . Config::RS_HOST ;
360384 }
361385
386+ private function getArHost ()
387+ {
388+ $ scheme = "http:// " ;
389+ if ($ this ->config ->useHTTPS == true ) {
390+ $ scheme = "https:// " ;
391+ }
392+ return $ scheme . Config::ARGUS_HOST ;
393+ }
394+
362395 private function getApiHost ()
363396 {
364397 $ scheme = "http:// " ;
@@ -386,6 +419,12 @@ private function rsGet($path)
386419 return $ this ->get ($ url );
387420 }
388421
422+ private function arPost ($ path , $ body = null )
423+ {
424+ $ url = $ this ->getArHost () . $ path ;
425+ return $ this ->pluPost ($ url , 'POST ' , $ body );
426+ }
427+
389428 private function get ($ url )
390429 {
391430 $ headers = $ this ->auth ->authorization ($ url );
@@ -407,6 +446,19 @@ private function post($url, $body)
407446 return array ($ r , null );
408447 }
409448
449+ private function pluPost ($ url , $ method , $ body )
450+ {
451+ $ headers = $ this ->auth ->authorizationV2 ($ url , $ method , $ body , 'application/json ' );
452+ $ headers ['Content-Type ' ]='application/json ' ;
453+ $ ret = Client::post ($ url , $ body , $ headers );
454+ if (!$ ret ->ok ()) {
455+ print ($ ret ->statusCode );
456+ return array (null , new Error ($ url , $ ret ));
457+ }
458+ $ r = ($ ret ->body === null ) ? array () : $ ret ->json ();
459+ return array ($ r , null );
460+ }
461+
410462 public static function buildBatchCopy ($ source_bucket , $ key_pairs , $ target_bucket , $ force )
411463 {
412464 return self ::twoKeyBatch ('/copy ' , $ source_bucket , $ key_pairs , $ target_bucket , $ force );
0 commit comments