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

WBOY
發布: 2016-06-06 20:27:41
原創
1149 人瀏覽過

好奇怪 官方的文档上明明写了
此 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>
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!