@@ -483,4 +483,68 @@ protected function normalizeVisibility(string $visibility): string
483483 default => 'default ' ,
484484 };
485485 }
486+
487+ /**
488+ * Part Upload - Init Upload
489+ *
490+ * @param string $path
491+ * @param Config $config
492+ *
493+ * @return array
494+ * @throws \Overtrue\CosClient\Exceptions\InvalidConfigException
495+ */
496+ public function createUploadId (string $ path , Config $ config ): array
497+ {
498+ $ prefixedPath = $ this ->prefixer ->prefixPath ($ path );
499+ $ response = $ this ->getObjectClient ()->createUploadId ($ prefixedPath , $ config ->get ('headers ' , []));
500+
501+ if (!$ response ->isSuccessful ()) {
502+ throw new \Exception ("Init Part Upload Failed! " );
503+ }
504+
505+ return Transformer::toArray ($ response ->getBody ());
506+ }
507+
508+ /**
509+ * Part Upload - Upload Part
510+ *
511+ * @param string $path
512+ * @param int $partNumber
513+ * @param string $uploadId
514+ * @param string $contents
515+ * @param Config $config
516+ *
517+ * @return array
518+ * @throws \Overtrue\CosClient\Exceptions\InvalidConfigException
519+ */
520+ public function uploadPart (string $ path , int $ partNumber , string $ uploadId , string $ contents , Config $ config ): array
521+ {
522+ $ prefixedPath = $ this ->prefixer ->prefixPath ($ path );
523+ $ response = $ this ->getObjectClient ()->uploadPart ($ prefixedPath , $ partNumber , $ uploadId , $ contents , $ config ->get ('headers ' , []));
524+ if (!$ response ->isSuccessful ()) {
525+ throw new \Exception ("Part Upload Failed! " );
526+ }
527+ return $ response ->getHeaders ();
528+ }
529+
530+ /**
531+ * Part Upload - Complete Upload
532+ *
533+ * @param string $path
534+ * @param string $uploadId
535+ * @param array $body
536+ *
537+ * @return array
538+ * @throws \Overtrue\CosClient\Exceptions\InvalidConfigException
539+ */
540+ public function markUploadAsCompleted (string $ path , string $ uploadId , array $ body ): array
541+ {
542+ $ prefixedPath = $ this ->prefixer ->prefixPath ($ path );
543+ $ response = $ this ->getObjectClient ()->markUploadAsCompleted ($ prefixedPath , $ uploadId , $ body );
544+ if (!$ response ->isSuccessful ()) {
545+ throw new \Exception ("Complete Part Upload Failed! " );
546+ }
547+
548+ return Transformer::toArray ($ response ->getBody ());
549+ }
486550}
0 commit comments