123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /*
- * Krpano100 oss上传下载文件
- * ============================================================================
- * 技术支持:2015-2099 成都世纪川翔科技有限公司
- * 官网地址: http://www.krpano100.com
- * ----------------------------------------------------------------------------
- * $Author: wanghao 932625974#qq.com $
- * $Id: index.php 28028 2016-03-09Z wanghao $
- */
- if(!defined('IN_T'))
- {
- die('hacking attempt');
- }
- require_once __DIR__.'/../krpano/cls_common_operation.php';
- require_once 'cls_oss_factory.php';
- class Oss extends KrOperation
- {
-
- public function downloadFile($obj , $localfile){
- $ossClient = Oss_Factory::getOssClient();
- $options = array(
- $ossClient::OSS_FILE_DOWNLOAD => $localfile,
- );
- try{
- $ossClient->getObject($GLOBALS['_lang']['oss_config']['bucket'], $obj, $options);
- } catch(OssException $e) {
- printf($e->getMessage() . "\n");
- return null;
- }
- return $localfile;
- }
- public function uploadFile($local_file , $origin_file){
- $ossClient = Oss_Factory::getOssClient();
- try{
- $ossClient->uploadFile($GLOBALS['_lang']['oss_config']['bucket'],$origin_file, $local_file);
- } catch(OssException $e) {
- printf($e->getMessage() . "\n");
- return;
- }
- }
- public function video_thumb($obj,$time){
- $thumb = 'video_thumb/'.Common::guid().'.jpg';
- $arr = array(
- 'Action' => 'SubmitSnapshotJob',
- 'Input' => '{"Bucket":"'.$GLOBALS['_lang']['oss_config']['bucket'].'","Location":"'.$GLOBALS['_lang']['oss_config']['location'].'","Object":"'.$obj.'"}',
- 'SnapshotConfig' => '{"OutputFile": {"Bucket": "'.$GLOBALS['_lang']['oss_config']['location'].'","Location": "'.$GLOBALS['_lang']['oss_config']['location'].'","Object": "'.$thumb.'"},"Time": "'.($time*1000).'","FrameType":"normal"}'
- );
- $ossMts = Oss_Factory::getOssMts();
- $result = Curl::callWebServer($ossMts->getSignUrl($arr));
- if($result['SnapshotJob']['State']=='Success')
- return $GLOBALS['_lang']['cdn_host'].$thumb;
- else
- return $GLOBALS['_lang']['host'].'static/images/def_video_thumb.jpg';
- }
- }
- ?>
|