七牛云存储 - 七牛云 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 학습자의 빠른 성장을 도와주세요!