下载object
@param string $bucket (Required)
@param string $object (Required)
@param array $opt (Optional)
fileWriteTo   (Optional)直接将请求结果写入该文件，如果fileWriteTo文件存在，sdk进行重命名再存储
@throws BCS_Exception
@return BCS_ResponseCore
353946
public function get_object($bucket, $object, $opt = array()) {
		$this->assertParameterArray ( $opt );
		//若fileWriteTo待写入的文件已经存在，需要进行重命名
		if (isset ( $opt ["fileWriteTo"] ) && file_exists ( $opt ["fileWriteTo"] )) {
			$original_file_write_to = $opt ["fileWriteTo"];
			$arr = explode ( DIRECTORY_SEPARATOR, $opt ["fileWriteTo"] );
			$file_name = $arr [count ( $arr ) - 1];
			$num = 1;
			while ( file_exists ( $opt ["fileWriteTo"] ) ) {
				$new_name_arr = explode ( ".", $file_name );
				if (count ( $new_name_arr ) > 1) {
					$new_name_arr [count ( $new_name_arr ) - 2] .= " ($num)";
				} else {
					$new_name_arr [0] .= " ($num)";
				}
				$arr [count ( $arr ) - 1] = implode ( ".", $new_name_arr );
				$opt ["fileWriteTo"] = implode ( DIRECTORY_SEPARATOR, $arr );
				$num ++;
			}
			$this->log ( "[$original_file_write_to] already exist, rename it to [" . $opt ["fileWriteTo"] . "]", $opt );
		}
		$opt [self::BUCKET] = $bucket;
		$opt [self::METHOD] = 'GET';
		$opt [self::OBJECT] = $object;
		$response = $this->authenticate ( $opt );
		$this->log ( $response->isOK () ? "Get object success!" : "Get object failed! Response: [" . $response->body . "]", $opt );
		if (! $response->isOK () && isset ( $opt ["fileWriteTo"] )) {
			unlink ( $opt ["fileWriteTo"] );
		}
		return $response;
	}
23082
public function listFiles($bucket, $limit=1000, $prefix='', $marker='', $delimiter=''){
        list($ret, $err) = $this->bucketManager->listFiles($bucket, $prefix, $marker, $limit, $delimiter);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
976959
public function export(PortableElementObject $object)
    {
        $zip = new \ZipArchive();
        $path = $this->getZipLocation($object);

        if ($zip->open($path, \ZipArchive::CREATE) !== TRUE) {
            throw new \common_Exception('Unable to create zipfile ' . $path);
        }

        $manifest = $this->getManifest($object);
        $zip->addFromString($this->getModel()->getManifestName(), $manifest);

        $files = $this->getFilesFromPortableElement($object);

        $filesystem = $this->getFileSystem();
        foreach ($files as $file) {
            if(strpos($file, './') === 0){
                //only export the files that are in the portable element package (exclude the shared libraries)
                $zip->addFromString($file, $filesystem->getFileContentFromModelStorage($object, $file));
            }
        }

        $zip->close();
        return $path;
    }
325041
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) {
			foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) {
				$output .= "\x0a";
				$output .= Binary::encodeVarint(strlen($v));
				$output .= $v;
			}
		}

		if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) {
			$output .= "\x12";
			$output .= Binary::encodeVarint(strlen($object->parameter));
			$output .= $object->parameter;
		}

		if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) {
			foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) {
				$output .= "\x7a";
				$buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
552185
public function generate_put_object_url($bucket, $object, $opt = array()) {
		$this->assertParameterArray ( $opt );
		return $this->generate_user_url ( "PUT", $bucket, $object, $opt );
	}
1137827
public function uploadFile($bucket, $object, $file, $options = NULL)
    {
        $this->precheckCommon($bucket, $object, $options);
        OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid");
        $file = OssUtil::encodePath($file);
        if (!file_exists($file)) {
            throw new OssException($file . " file does not exist");
        }
        $options[self::OSS_FILE_UPLOAD] = $file;
        $file_size = filesize($options[self::OSS_FILE_UPLOAD]);
        $is_check_md5 = $this->isCheckMD5($options);
        if ($is_check_md5) {
            $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
            $options[self::OSS_CONTENT_MD5] = $content_md5;
        }
        if (!isset($options[self::OSS_CONTENT_TYPE])) {
            $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file);
        }
        $options[self::OSS_METHOD] = self::OSS_HTTP_PUT;
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_OBJECT] = $object;
        $options[self::OSS_CONTENT_LENGTH] = $file_size;
        $response = $this->auth($options);
        $result = new PutSetDeleteResult($response);
        return $result->getData();
    }
623501
public function generate_head_object_url($bucket, $object, $opt = array()) {
		$this->assertParameterArray ( $opt );
		return $this->generate_user_url ( "HEAD", $bucket, $object, $opt );
	}
300006
public function appendFile($bucket, $object, $file, $position, $options = NULL)
    {
        $this->precheckCommon($bucket, $object, $options);

        OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid");
        $file = OssUtil::encodePath($file);
        if (!file_exists($file)) {
            throw new OssException($file . " file does not exist");
        }
        $options[self::OSS_FILE_UPLOAD] = $file;
        $file_size = filesize($options[self::OSS_FILE_UPLOAD]);
        $is_check_md5 = $this->isCheckMD5($options);
        if ($is_check_md5) {
            $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true));
            $options[self::OSS_CONTENT_MD5] = $content_md5;
        }
        if (!isset($options[self::OSS_CONTENT_TYPE])) {
            $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file);
        }

        $options[self::OSS_METHOD] = self::OSS_HTTP_POST;
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_OBJECT] = $object;
        $options[self::OSS_CONTENT_LENGTH] = $file_size;
        $options[self::OSS_SUB_RESOURCE] = 'append';
        $options[self::OSS_POSITION] = strval($position);

        $response = $this->auth($options);
        $result = new AppendResult($response);
        return $result->getData();
    }
366948
public static function serialize( $object, $fileName )
	{
		$serial	= parent::serialize( $object );
		$file	= new FS_File_Writer( $fileName );
		return $file->writeString( $serial );
	}
678197
private function headObject($object_name) {
    $headers = $this->getOAuthTokenHeader(parent::READ_SCOPE);
    if ($headers === false) {
      if (!$this->quiet) {
        trigger_error("Unable to acquire OAuth token.", E_USER_WARNING);
      }
      return false;
    }

    $url = $this->createObjectUrl($this->bucket_name, $object_name);
    $http_response = $this->makeHttpRequest($url, "HEAD", $headers);
    if ($http_response === false) {
      if (!$this->quiet) {
        trigger_error('Unable to connect to the Cloud Storage Service.',
                      E_USER_WARNING);
      }
      return false;
    }

    $status_code = $http_response['status_code'];
    if (HttpResponse::OK !== $status_code) {
      if (!$this->quiet && HttpResponse::NOT_FOUND !== $status_code) {
        trigger_error($this->getErrorMessage($http_response['status_code'],
                                             $http_response['body']),
                      E_USER_WARNING);
      }
      return false;
    }

    $headers = $http_response['headers'];
    return ['size' => $this->getHeaderValue('x-goog-stored-content-length',
                                            $headers),
            'mtime' => $this->getHeaderValue('Last-Modified', $headers)];
  }
951679
public function arrangeObject($object, $order = array())
    {

        if (!is_object($object))
            throw new Exception("Please provide a valid Object for the arrangeObject method");
        if (!is_array($order) || empty($order))
            throw new Exception("Please provide a valid orderArray for the arrangeObject method");

        $obj = new stdClass();

        foreach ($order as $key) {
            $obj->$key = $object->$key;
        }
        return $obj;
    }
1237792
public function generate_get_object_url($bucket, $object, $opt = array()) {
		$this->assertParameterArray ( $opt );
		return $this->generate_user_url ( "GET", $bucket, $object, $opt );
	}
201178
private function sign($method, $Bucket, $object='/', $size=''){
        if(!$size)
            $size = $this->config['size'];
        $param = array(
            'ak'=>$this->config['AccessKey'],
            'sk'=>$this->config['SecretKey'],
            'size'=>$size,
            'bucket'=>$Bucket,
            'host'=>self :: DEFAULT_URL,
            'date'=>time()+$this->config['timeout'],
            'ip'=>'',
            'object'=>$object
        );
        $response = $this->request($this->apiurl.'?'.http_build_query($param), 'POST');
        if($response)
            $response = json_decode($response, true);
        return $response['content'][$method];
    }
565332
public function putObject(string $bucket, string $object, string $content)
    {
        try {
            $response = $this->client->putObject($bucket, $object, $content);
            return $this->success('上传文件成功', $response['info']);
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }
913602
public static function serialize($object)
    {
        $transport = new TMemoryBuffer();
        $protocol = new TBinaryProtocolAccelerated($transport);
        if (function_exists('thrift_protocol_write_binary')) {
            thrift_protocol_write_binary(
                $protocol,
                $object->getName(),
                TMessageType::REPLY,
                $object,
                0,
                $protocol->isStrictWrite()
            );

            $protocol->readMessageBegin($unused_name, $unused_type, $unused_seqid);
        } else {
            $object->write($protocol);
        }
        $protocol->getTransport()->flush();

        return $transport->getBuffer();
    }
18437
public function delete_bucket($bucket, $opt = array()) {
		$this->assertParameterArray ( $opt );
		$opt [self::BUCKET] = $bucket;
		$opt [self::METHOD] = 'DELETE';
		$opt [self::OBJECT] = '/';
		$response = $this->authenticate ( $opt );
		$this->log ( $response->isOK () ? "Delete bucket success!" : "Delete bucket failed! Response: [" . $response->body . "]", $opt );
		return $response;
	}
523668
public function getObject(string $bucket, string $object)
    {
        try {
            $content = $this->client->getObject($bucket, $object);
            return $this->success('获取文件成功', ['object' => $content]);
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }