public static function fromJson($json)
 {
     // Currently, we only support json object
     if (is_object($json)) {
         $result = new PutObjectResult();
         if (isset($json->bucketName)) {
             $result->setBucketName($json->bucketName);
         }
         if (isset($json->objectName)) {
             $result->setObjectName($json->objectName);
         }
         if (isset($json->accessKeyId)) {
             $result->setAccessKeyId($json->accessKeyId);
         }
         if (isset($json->signature)) {
             $result->setSignature($json->signature);
         }
         if (isset($json->expires)) {
             $result->setExpires($json->expires);
         }
         return $result;
     }
     return NULL;
 }
 public function completeMultipartUpload($bucket_name, $object_name, $upload_id, $metadata, $upload_part_result_list)
 {
     $uri = $this->fds_config->getBaseUri() . $bucket_name . "/" . $object_name . "?uploadId=" . $upload_id;
     $headers = $this->prepareRequestHeader($uri, Http::PUT, Mime::JSON);
     $response = $this->invoke(Action::CompleteMultipartUpload, $uri, $headers, Http::PUT, null, json_encode($upload_part_result_list));
     if ($response->code == self::HTTP_OK) {
         $result = PutObjectResult::fromJson($response->body);
         return $result;
     } else {
         $message = "Complete multipart failed, status=" . $response->code . ", reason=" . $response->raw_body;
         $this->printResponse($response);
         throw new GalaxyFDSClientException($message);
     }
 }
 public function postObject($bucket_name, $content, $metadata = NULL)
 {
     $uri = $this->formatUri($this->fds_config->getUploadBaseUri(), $bucket_name . "/");
     if ($this->fds_config->isEnableMd5Calculate()) {
         if ($metadata == NULL) {
             $metadata = new FDSObjectMetadata();
         }
         $metadata->setContentMD5(md5($content));
     }
     $header = $this->prepareRequestHeader($uri, Http::POST, self::APPLICATION_OCTET_STREAM, $metadata);
     $response = $this->invoke(Action::PostObject, $uri, $header, Http::POST, null, $content);
     if ($response->code == self::HTTP_OK) {
         $result = PutObjectResult::fromJson($response->body);
         return $result;
     } else {
         $message = "Post object failed, status=" . $response->code . ", bucket_name=" . $bucket_name . ", reason=" . $response->raw_body;
         $this->printResponse($response);
         throw new GalaxyFDSClientException($message);
     }
 }