123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- require_once dirname(__FILE__) . '/txcloud/include.php');
-
- class TxCloud_Lite {
- protected $config;
-
- public function __construct($config = NULL) {
- $this->config = $config;
- if ($this->config === NULL) {
- $this->config = DI()->config->get('app.TxCloud');
- }
- }
-
- public function uploadFile($file)
- {
- $fileUrl = '';
-
- $folder = '/test2';
-
- $dst = '/test2/'.$file["name"];
-
- $bucket = 'aosika';
-
-
- $src = $file["tmp_name"];
- if (!file_exists($dst)) {
- return $fileUrl;
- }
- $config = $this->config;
-
-
-
- date_default_timezone_set('PRC');
- $cosApi = new \QCloud\Cos\Api($config['config']);
-
- $ret = $cosApi->createFolder($bucket, $folder);
-
-
- $ret = $cosApi->upload($bucket, $src, $dst);
-
- return $fileUrl;
- }
-
-
- public function createReusableSignatureImg($filepath)
- {
- $bucket = 'aosika';
- $config = $this->config;
- $filepath = '/test2/1.jpg';
- $expiration = time() + 3600;
- $auth = new \QCloud\Cos\Auth($config['app_id'], $config['secret_id'], $config['secret_key']);
- $signature = $auth->createReusableSignature($expiration, $bucket, $filepath);
- return $signature;
- }
-
- public function createReusableSignatureMP4($filepath)
- {
- $bucket = 'aosika';
- $config = $this->config;
- $filepath = '/test2/2.mp4';
- $expiration = time() + 3600;
- $auth = new \QCloud\Cos\Auth($config['app_id'], $config['secret_id'], $config['secret_key']);
- $signature = $auth->createReusableSignature($expiration, $bucket, $filepath);
- return $signature;
- }
-
- public function createNonreusableSignature($filepath)
- {
- $bucket = 'aosika';
- $config = $this->config;
-
- $auth = new \QCloud\Cos\Auth($config['app_id'], $config['secret_id'], $config['secret_key']);
- $signature = $auth->createNonreusableSignature($bucket, $filepath);
- return $signature;
- }
-
- }
|