批量修改文件MIME

@param $bucket
@param $keys
@param $mime
@return array
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);
    }
136675
public function changeType($bucket, $key, $type){
        if(!in_array($type, [0, 1])){
            return $this->error('文件存储类型错误', ['errorCode'=>-1]);
        }
        $err = $this->bucketManager->changeType($bucket, $key, $type);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功');
    }
1266839
public function dropBucket($bucket)
    {
        $path = "/drop/".$bucket;
        list(, $error) = $this->rsPost($path);
        return $error;
    }
736197
private function createBucket($path, array $params)
    {
        if ($this->getClient()->doesBucketExist($params['Bucket'])) {
            return $this->triggerError("Bucket already exists: {$path}");
        }

        return $this->boolCall(function () use ($params, $path) {
            $this->getClient()->createBucket($params);
            $this->clearCacheKey($path);
            return true;
        });
    }
980119
private function delBase($bucket, $path)
    {
        if ($path == "/") {
            return [
                'code'      => Response::COSAPI_PARAMS_ERROR,
                'message'   => 'can not delete bucket using api! go to ' .
                    'http://console.qcloud.com/cos to operate bucket'
            ];
        }

        $path       = self::cosUrlEncode($path);
        $url        = self::generateResUrl($bucket, $path);
        $signature  = $this->createNonreusableSignature($bucket, $path);
        $data       = ['op' => 'delete'];
        $data       = json_encode($data);

        $req = [
            'url'       => $url,
            'method'    => 'post',
            'timeout'   => self::$timeout,
            'data'      => $data,
            'header'    => [
                'Authorization: ' . $signature,
                'Content-Type: application/json',
            ],
        ];

        return self::sendRequest($req);
    }
1241171
public static String encodedEntry(String bucket, String key) {
        String encodedEntry;
        if (key != null) {
            encodedEntry = UrlSafeBase64.encodeToString(bucket + ":" + key);
        } else {
            encodedEntry = UrlSafeBase64.encodeToString(bucket);
        }
        return encodedEntry;
    }
1086329
public function uploadToken($bucket, $key = null, $expires = 3600, $policy = null, $strictPolicy = true){
        $token = $this->auth->uploadToken($bucket, $key, $expires, $policy, $strictPolicy);
        return $this->success('操作成功', $token);
    }
38930
public function sRem($key, $member, ...$members) {
        return $this->send(array_merge(['srem', $key], (array) $member, $members));
    }
1353108
public function getObjectAcl($bucket, $key)
    {
        $params = [
            'Bucket' => $bucket,
            'Key'    => $key
        ];

        return $this->instance->getObjectAcl($params);
    }
498309
public static function getExtensionsFromMime($mime, $all = false)
    {
        self::initMimeTypes();

        $result = $all ? [] : '';

        foreach (self::$mimeTypes as $ext => $mimeType)
        {
            if ($mime == $mimeType)
            {
                if ($all)
                {
                    $result[] = $ext;
                }
                else
                {
                    $result = $ext;
                    break;
                }
            }
        }
        return $result;
    }
23082
public function listFiles($bucket, $limit=1000, $prefix='', $marker='', $delimiter=''){
        list($ret, $err) = $this->bucketManager->listFiles($bucket, $prefix, $marker, $limit, $delimiter);
        if($err){
            return $this->error($err->message(), ['errorCode'=>$err->code()]);
        }
        return $this->success('操作成功', $ret);
    }
1318391
public function delete($bucket, $key)
    {
        $path = '/delete/' . \Qiniu\entry($bucket, $key);
        list(, $error) = $this->rsPost($path);
        return $error;
    }
1208476
public function uploadByUrl($url, $key = null, $bucket = '')
    {
        $filePath = tempnam(sys_get_temp_dir(), 'QN');
        copy($url, $filePath);
        $result = $this->uploadFile($filePath, $key, $bucket);
        unlink($filePath);
        return $result;
    }
467811
public function mime($mime = null)
    {
        if (!func_num_args()) {
            return $this->_mime;
        }
        return $this->_mime = static::getMime($this, $mime);
    }
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);
    }
1283711
private function validMimeImage($extension, $mimes)
    {
        if (is_array($mimes)) {
            foreach ($mimes as $mime) {
                if (!strstr($mime, 'image/')) {
                    throw new \InvalidArgumentException(htmlspecialchars(
                        "The extension $extension is not an image extension."
                    ));
                }
            }
        } else {
            if (!strstr($mimes, 'image/')) {
                throw new \InvalidArgumentException(htmlspecialchars(
                    "The extension $extension is not an image extension."
                ));
            }
        }
    }
1322030
public function multipartUpload($bucket, $key, $sourcePath, $concurrency = 1)
    {
        $uploader = new MultipartUploader($this->instance, $sourcePath, [
            'bucket' => $bucket,
            'key'    => $key,
        ]);

        try {
            $uploader->upload();

            return true;
        } catch (MultipartUploadException $e) {
            return false;
        }
    }