镜像资源更新

@param $bucket
@param $key
@return array
508987
public function prefetch($bucket, $key){
        $err = $this->bucketManager->prefetch($bucket, $key);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功');
    }
1205272
function changed($key=NULL) {
		if (isset($key))
			return $this->fields[$key]['changed'];
		foreach($this->fields as $key=>$field)
			if ($field['changed'])
				return TRUE;
		return FALSE;
	}
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);
    }
1229146
private function isBucketWritable($bucket) {
    $cache_key_name = sprintf(parent::WRITABLE_MEMCACHE_KEY_FORMAT, $bucket);
    $memcache = new \Memcache();
    $result = $memcache->get($cache_key_name);

    if ($result) {
      return $result['is_writable'];
    }

    // We determine if the bucket is writable by trying to start a resumable
    // upload. GCS will cleanup the abandoned upload after 7 days, and it will
    // not be charged to the bucket owner.
    $token_header = $this->getOAuthTokenHeader(parent::WRITE_SCOPE);
    if ($token_header === false) {
      return false;
    }
    $headers = array_merge(parent::$upload_start_header, $token_header);
    $url = parent::createObjectUrl($bucket, parent::WRITABLE_TEMP_FILENAME);
    $http_response = $this->makeHttpRequest($url,
                                            "POST",
                                            $headers);

    if ($http_response === false) {
      return false;
    }

    $status_code = $http_response['status_code'];
    $is_writable = $status_code == HttpResponse::CREATED;

    $memcache->set($cache_key_name,
                   ['is_writable' => $is_writable],
                   null,
                   $this->context_options['writable_cache_expiry_seconds']);
    return $is_writable;
  }
811218
public function batchDeleteAfterDays($bucket, $keys, $days){
        $keyDayPairs = array();
        foreach ($keys as $key) {
            $keyDayPairs[$key] = $days;
        }
        $ops = $this->bucketManager->buildBatchDeleteAfterDays($bucket, $keyDayPairs);
        list($ret, $err) = $this->bucketManager->batch($ops);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
1084471
public function createBucket($bucket, $region='z0'){
        $err = $this->subBucketManager->createBucket($bucket, $region);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功');
    }
372821
public function count($bucket){
        $amount = 0;
        $flag = true;
        $marker = '';
        while ($flag){
            $response = $this->listFiles($bucket, 1000, '', $marker);
            if(!$response['success']){
                return $response;
            }
            $marker = isset($response['data']['marker']) ? $response['data']['marker'] : '';
            $items = $response['data']['items'];
            $amount += count($items);
            if(!$marker){
                $flag = false;
            }
        }
        return $this->success('操作成功', ['amount'=>$amount]);
    }
1015484
public static function setObjectACL($key, $bucket, $acl = 'public-read')
    {
        $s3c = self::getS3C();
        if ($s3c->doesObjectExist($bucket, $key)) {
            $result = $s3c->putObjectAcl(array(
                'ACL' => $acl,
                'Bucket' => $bucket,
                'Key' => $key,
            ));
            if ($result) {
                return true;
            }
        }

        return false;
    }
1269632
@Override
    public Object remove(K key) {
        for (Map<K, V> bucket : buckets) {
            Object value = bucket.remove(key);
            if (value != null) {
                return value;
            }
        }
        return null;
    }
434211
public function uploadToken(
        $bucket = null,
        $key = null,
        $expires = 3600,
        $policy = null)
    {
        // 默认使用当前配置的bucket
        if ($bucket === null) {
            $bucket = $this->bucket;
        }
        return $this->auth->uploadToken(
            $bucket,
            $key,
            $expires,
            $policy,
            true
        );
    }
1256855
protected function buildPath($type, $bucket, $key)
    {
        if ($type === null) {
            return sprintf('/buckets/%s/keys/%s', $bucket, $key);
        }

        return sprintf('/types/%s/buckets/%s/keys/%s', $type, $bucket, $key);
    }
713783
protected function insert($key)
    {
        if ($this->after($key) === null || $this->after($key) === '') {
            return false;
        }

        $this->differ->setRenderer(new Renderers\Insert);

        $value = $this->before($key)
                    ? $this->differ->render($this->before($key), $this->after($key))
                    : $this->after($key);

        $diff = [
            'key' => $key,
            'value' => $value,
            'type' => 'insert',
        ];

        return (object) $diff;
    }
1335665
protected function insertBetween($key, $value, Bucket $prev, Bucket $next): void
    {
        $bucket = new KeyValueBucket($key, $value);

        $prev->setNext($bucket);
        $next->setPrev($bucket);

        $bucket->setPrev($prev);
        $bucket->setNext($next);

        $this->current = $bucket;
        $this->count++;
    }
413287
private function uploadMedia($fileName, $bucket, $key)
    {
        // init multi-part upload
        $initUploadResponse = $this->bosClient->initiateMultipartUpload($bucket, $key);
        $uploadId = $initUploadResponse->uploadId;

        // do upload part
        try {
            $offset = 0;
            $partNumber = 1;
            $partSize = BosClient::MIN_PART_SIZE;
            $length = $partSize;
            $partList = array();
            $bytesLeft = filesize($fileName);

            while ($bytesLeft > 0) {
                $length = ($length > $bytesLeft) ? $bytesLeft : $length;
                $uploadResponse = $this->bosClient->uploadPartFromFile(
                    $bucket,
                    $key,
                    $uploadId,
                    $partNumber,
                    $fileName,
                    $offset,
                    $length);
                array_push($partList, array(
                    'partNumber' => $partNumber,
                    'eTag' => $uploadResponse->metadata['etag'],
                ));
                $offset += $length;
                $partNumber++;
                $bytesLeft -= $length;
            }

            // complete upload
            $this->bosClient->completeMultipartUpload($bucket, $key, $uploadId, $partList);
        } catch (\Exception $e) {
            $this->bosClient->abortMultipartUpload($bucket, $key, $uploadId);
            throw $e;
        }
    }
1325344
public function work_running($bucket = self::DEFAULT_BUCKET)
	{
		$results = array();
		foreach ($this->forked_children as $pid => $child)
		{
			if ($child['status'] != self::STOPPED && $child['bucket'] === $bucket)
			{
				$results[$pid] = $child;
			}
		}

		return $results;
	}
808528
public function doesObjectExist($bucket, $key, array $params = [])
    {
        return $this->instance->doesObjectExist($bucket, $key, $params);
    }
928086
public function listObjects($bucket, $marker = null, $maxKeys = 10, $delimiter = '', $prefix = '')
    {
        try {
            $options = [];
            $marker && $options['marker'] = $marker;
            $delimiter && $options['delimiter'] = $delimiter;
            $maxKeys && $options['max-keys'] = $maxKeys;
            $prefix && $options['prefix'] = $prefix;
            $objects = $this->client->listObjects($bucket, $options)->getObjectList();
            return $this->success('获取成功', ['objects' => $objects]);
        } catch (\Exception $exception) {
            return $this->error('调用阿里云接口出错：' . $exception->getMessage());
        }
    }