PHP code example of gk-qcloudapi-sdk-php / cospackage

1. Go to this page and download the library: Download gk-qcloudapi-sdk-php/cospackage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gk-qcloudapi-sdk-php / cospackage example snippets


 $app->register(Gkcosapi\Cospackage\CospackageServiceProvider::class);
 $app->configure('cospackage');

> 如果需要新增路由模块需要如下操作
> 注意:
> 1、需要在Http/controllers/创建Objectstore目录且复制扩展包DEMO目录中的VodapiController文件到该目录
> 2、扩展包DEMO目录中的cos.php复制到routes目录中
> 3、将下列代码一并写入bootstrap/app.php

$app->router->group([
    'prefix' => env('APP_VERSION') . '/api/cos',
    'namespace' => 'App\Http\Controllers\Objectstore',
], function ($router) {
    

composer 

Cospackage::uploadFile($file->getPathname(), 'jpg');

Cospackage::uploadFile($file->getPathname(), 'jpg');//cos文件上传工作

Cospackage::getResource($url)//获取文件资源

Cospackage::getUploadSign($fileType = "image", $method = "post")//获取cos签名

Cospackage::getUploadParam($key)//获取文件上传参数 key:定义的文件目录名称或mercharID(生成目录)