Home  >  Article  >  Backend Development  >  七牛云存储 - 七牛云 V7 版本的PHP SDK 是不是还没有做完,为什么找不到删除,移动资源的功能?

七牛云存储 - 七牛云 V7 版本的PHP SDK 是不是还没有做完,为什么找不到删除,移动资源的功能?

WBOY
WBOYOriginal
2016-06-06 20:27:411148browse

好奇怪 官方的文档上明明写了
此 SDK 包含了如下几个功能:

数据的上传和下载。

数据的管理: 复制,移动,删除,获取元信息,列取文件。

数据的处理: 图片的处理,音视频的处理,文档的处理。

这咋这么不负责任呢?

回复内容:

好奇怪 官方的文档上明明写了
此 SDK 包含了如下几个功能:

数据的上传和下载。

数据的管理: 复制,移动,删除,获取元信息,列取文件。

数据的处理: 图片的处理,音视频的处理,文档的处理。

这咋这么不负责任呢?

七牛这些功能都有啊,你可以看看他们源码:

https://github.com/qiniu/php-sdk/tree/v7.0.4

你说的这些功能代码里面都有的。

<code>use Qiniu\Storage\BucketManager;
$bucketMgr = New BucketManager($this->auth);

$bucketMgr->move(...);
$bucketMgr->delete(...);</code>

一找就找到了

查看:https://github.com/qiniu/php-sdk/blob/v7.0.4/src/Qiniu/Storage/BucketManager.php
有相应的方法

<code>/**
     * 删除指定资源
     *
     * @param $bucket     待删除资源所在的空间
     * @param $key        待删除资源的文件名
     *
     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
     * @link  http://developer.qiniu.com/docs/v6/api/reference/rs/delete.html
     */
    public function delete($bucket, $key)
    {
        $path = '/delete/' . \Qiniu\entry($bucket, $key);
        list(, $error) = $this->rsPost($path);
        return $error;
    }
    /**
     * 给资源进行重命名,本质为move操作。
     *
     * @param $bucket     待操作资源所在空间
     * @param $oldname    待操作资源文件名
     * @param $newname    目标资源文件名
     *
     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
     */
    public function rename($bucket, $oldname, $newname)
    {
        return $this->move($bucket, $oldname, $bucket, $newname);
    }
    /**
     * 给资源进行重命名,本质为move操作。
     *
     * @param $from_bucket     待操作资源所在空间
     * @param $from_key        待操作资源文件名
     * @param $to_bucket       目标资源空间名
     * @param $to_key          目标资源文件名
     *
     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
     * @link  http://developer.qiniu.com/docs/v6/api/reference/rs/copy.html
     */
    public function copy($from_bucket, $from_key, $to_bucket, $to_key)
    {
        $from = \Qiniu\entry($from_bucket, $from_key);
        $to = \Qiniu\entry($to_bucket, $to_key);
        $path = '/copy/' . $from . '/' . $to;
        list(, $error) = $this->rsPost($path);
        return $error;
    }
    /**
     * 将资源从一个空间到另一个空间
     *
     * @param $from_bucket     待操作资源所在空间
     * @param $from_key        待操作资源文件名
     * @param $to_bucket       目标资源空间名
     * @param $to_key          目标资源文件名
     *
     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
     * @link  http://developer.qiniu.com/docs/v6/api/reference/rs/move.html
     */
    public function move($from_bucket, $from_key, $to_bucket, $to_key)
    {
        $from = \Qiniu\entry($from_bucket, $from_key);
        $to = \Qiniu\entry($to_bucket, $to_key);
        $path = '/move/' . $from . '/' . $to;
        list(, $error) = $this->rsPost($path);
        return $error;
    }</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn