PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

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

原创
2016-06-06 20:27:41 863浏览

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

数据的上传和下载。

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

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

这咋这么不负责任呢?

回复内容:

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

数据的上传和下载。

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

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

这咋这么不负责任呢?

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

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

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

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

$bucketMgr->move(...);
$bucketMgr->delete(...);

一找就找到了

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

/**
     * 删除指定资源
     *
     * @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 . '//m.sbmmt.com/m/' . $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 . '//m.sbmmt.com/m/' . $to;
        list(, $error) = $this->rsPost($path);
        return $error;
    }
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。