将指定资源复制为新命名资源。http://developer.qiniu.com/docs/v6/api/reference/rs/copy.html
@param $key
@param $bucket2
@param bool $key2
@param string $bucket
@throws \Exception
184573
public function copy($key, $bucket2, $key2 = false, $bucket = '')
    {
        $bucket = $bucket ? $bucket : $this->bucket;
        if (!$key2) {
            $key2 = $bucket2;
            $bucket2 = $bucket;
        }
        $encodedEntryURISrc = self::urlBase64Encode("{$bucket}:{$key}");
        $encodedEntryURIDest = self::urlBase64Encode("{$bucket2}:{$key2}");
        $url = "/copy/{$encodedEntryURISrc}/{$encodedEntryURIDest}";
        return $this->fileHandle($url);
    }
787057
private function __connect(Memento\Key $key = null)
    {
        $connectKey = $this->groupKey ? $this->groupKey : $key;
        $config = $this->getServer($connectKey, $this->config);
        if (!array_key_exists('host', $config)) {
            throw new \Exception("Invalid redis configuration");
        }

        if (!array_key_exists('port', $config)) {
            $config['port'] = 11211;
        }

        // instantiate to the redis interface
        $this->redis = new Predis\Client($config);
    }
937161
public function batchStat($bucket, $keys){
        $ops = $this->bucketManager->buildBatchStat($bucket, $keys);
        list($ret, $err) = $this->bucketManager->batch($ops);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
531095
public function put($key, $item)
    {
        $file = $this->filename($key);

        // json
        // text
        if (!file_put_contents($file, serialize($item))) {
            throw new \Exception(
                t("Failed writing cache object '!key'.", [
                    '!key' => $key
                ])
            );
        }
    }
1292657
public function batchDelete($bucket, $keys){
        $ops = $this->bucketManager->buildBatchDelete($bucket, $keys);
        list($ret, $err) = $this->bucketManager->batch($ops);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
775695
public function changeType($bucket, $key, $fileType)
    {
        $resource = \Qiniu\entry($bucket, $key);
        $path = '/chtype/' . $resource . '/type/' . $fileType;
        list(, $error) = $this->rsPost($path);
        return $error;
    }
63977
public function protect($key) {
        if (!is_string($key)) {
            throw new \Calf\Exception\InvalidArgument('Key must be string.');
        }

        if (!isset($this->_keys[$key])) {
            throw new \Calf\Exception\Runtime('Key doesn\'t exists: ' . $key);
        }

        $this->_protected[$key] = true;
    }
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;
    }
353011
public function batchChangeMime($bucket, $keys, $mime){
        $keyMimePairs = array();
        foreach ($keys as $key) {
            $keyMimePairs[$key] = $mime;
        }
        $ops = $this->bucketManager->buildBatchChangeMime($bucket, $keyMimePairs);
        list($ret, $err) = $this->bucketManager->batch($ops);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
1221405
public function delete($key)
    {
        $this->init();
        list($containerName, $key) = $this->tokenizeKey($key);

        try {
            $this->blobProxy->deleteBlob($containerName, $key);

            return true;
        } catch (ServiceException $e) {
            $this->failIfContainerNotFound($e, sprintf('delete key "%s"', $key), $containerName);

            return false;
        }
    }
1306865
public static Key encodeKey(String bucket, String key) {
    Key res = encodeKeyImpl(bucket, key);
//    assert checkBijection(res, bucket, key);
    return res;
  }
808528
public function doesObjectExist($bucket, $key, array $params = [])
    {
        return $this->instance->doesObjectExist($bucket, $key, $params);
    }
728142
protected function writeNewEnvironmentFileWith($key)
    {
        file_put_contents($this->laravel->environmentFilePath(), preg_replace(
            $this->keyReplacementPattern(),
            'APP_KEY='.$key,
            file_get_contents($this->laravel->environmentFilePath())
        ));
    }
817796
protected function replaceRefs($key, &$scope)
    {
        if (is_array($scope)) {
            foreach (array_keys($scope) as $subkey) {
                $this->replaceRefs(
                    implode($this->delimiter, [$key, $subkey]),
                    $scope[$subkey]
                );
            }
        } else {
            $this->getByRef($key, $scope);
        }
    }
216707
public function stat($bucket, $key){
        list($fileInfo, $err) = $this->bucketManager->stat($bucket, $key);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $fileInfo);
    }
490470
public function bucket($key = null) {
        if (!$this->id) {
            throw new Exception("The server has no ID, can\'t get buckets");
        }

        $bucket = new Bucket($this->patrol);

        $bucket->defaults([
            'server_id' => $this->id
        ]);

        if (is_null($key)) {
            return $bucket;
        }

        try {
            return $bucket->find($key);
        } catch (Exception $ex) {
            if ($ex->getMessage() === "Bucket does not exist") {
                $bucket->key = $key;
                return $bucket;
            }
        }

        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
        );
    }