Since: 2012-05-31
Author: xiaobing
Example #1
0
 private function upload($data)
 {
     $data = explode('|', $data);
     $ch = curl_init($data[1]);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $img = curl_exec($ch);
     $info = curl_getinfo($ch);
     if (curl_errno($ch) > 0) {
         curl_close($ch);
         echo "{$data[1]} | {$data[0]} Failed \n";
         return;
     }
     curl_close($ch);
     require_once APP_DIR . 'vendors/objectstorage/sdk.class.php';
     require_once APP_DIR . 'vendors/objectstorage/util/oss_util.class.php';
     $oss = new \ALIOSS(OSS_ACCESS_ID, OSS_ACCESS_KEY, OSS_ENDPOINT);
     $object = "avatar/{$data[0]}";
     $content = $img;
     $options = array('Content-Type' => $info['content_type'], 'content' => $content, 'length' => strlen($content));
     $res = $oss->upload_file_by_content(OSS_TEST_BUCKET, $object, $options);
     \OSSUtil::print_res($res, "{$data[1]} | {$data[0]}");
     if (!$this->user->update(['avatar' => time()], ['uid' => $data[0]])) {
         echo " database updated failed. \n";
     }
 }
Example #2
0
 /**
  * @param  上传图片到aliyun oss
  * @param  [obj] 阿里云sdk  可不填
  * @param  [imgName] 图片名称
  * @param  [content] 图片地址
  * @param  [save_type] 保存图片时的模式  url=>表示传入url 上传 否则为图片的源数据
  * @return [ossImgUrl]
  */
 public function upload_by_content($obj = "", $imgName, $content, $save_type = 'url')
 {
     if (empty($obj)) {
         /**
          * 加载sdk包以及错误代码包
          */
         $sdkPath = dirname(__FILE__);
         require_once $sdkPath . '/sdk.class.php';
         $obj = new ALIOSS();
         //设置是否打开curl调试模式
         //$obj->set_debug_mode(FALSE);
         //设置开启三级域名,三级域名需要注意,域名不支持一些特殊符号,所以在创建bucket的时候若想使用三级域名,最好不要使用特殊字符
         $obj->set_enable_domain_style(TRUE);
     }
     $bucket = QRIMG_B;
     $folder = 'headimg/';
     $object = $folder . $imgName;
     if ($save_type == 'url') {
         $content = file_get_contents($content);
     } else {
         $content = $content;
     }
     $upload_file_options = array('content' => $content, 'length' => strlen($content), ALIOSS::OSS_HEADERS => array('Expires' => date('Y-m-d H:i:s', time() + 3600 * 24 * 10)));
     $response = $obj->upload_file_by_content($bucket, $object, $upload_file_options);
     //echo 'upload file {'.$object.'}'.($response->isOk()?'ok':'fail')."\n";
     //_format($response);
     return HTTP_IMG_HOST . $object;
 }
Example #3
0
 /**
  *
  */
 protected function &get_alioss()
 {
     require_once dirname(dirname(dirname(__FILE__))) . '/lib/ali-oss/sdk.class.php';
     $oss_sdk_service = new ALIOSS(null, null, $this->hostname);
     //设置是否打开curl调试模式
     $oss_sdk_service->set_debug_mode(FALSE);
     return $oss_sdk_service;
 }
Example #4
0
 /**
  * 初始化连接对象
  */
 private static function init()
 {
     if (!self::$conObj) {
         $ossSdkService = new ALIOSS();
         $ossSdkService->set_debug_mode(FALSE);
         //设置是否打开curl调试模式
         self::$conObj = $ossSdkService;
     }
     return self::$conObj;
 }
Example #5
0
 /**
  * 上传文件到oss
  * @param string $localPath
  * @param string $ossPath 在oss上的路径:
  * 	朋友圈	md5(member_id)/date('Y').date('m').date('d').'/'.pic.png
  * 	个人资料	md5(member_id)/pic.png
  * 
  * 
  */
 public static function upload($localPath, $ossPath)
 {
     $oss_sdk_service = new \ALIOSS();
     $oss_sdk_service->set_debug_mode(true);
     $bucket = BUCKET;
     $object = $ossPath;
     $file_path = $localPath;
     $response = $oss_sdk_service->upload_file_by_file($bucket, $object, $file_path);
     $header = $response->header;
     return $header['_info'];
 }
Example #6
0
 public function __construct($ak, $sk, $host, $bucket, $ns = '', $cdn = '')
 {
     parent::__construct($ak, $sk, $host);
     $this->bucket = $bucket;
     $this->host = $host;
     $this->ns = $ns;
     $this->cdn = $cdn;
 }
Example #7
0
function attachment_alioss_buctkets($key, $secret)
{
    require '../framework/library/alioss/sdk.class.php';
    $oss = new ALIOSS($key, $secret);
    $response = $oss->list_bucket();
    if (!empty($response)) {
        $xml = isimplexml_load_string($response->body, 'SimpleXMLElement', LIBXML_NOCDATA);
        $buckets = json_decode(json_encode($xml), true);
    }
    if (empty($buckets['Buckets']['Bucket'][0])) {
        $buckets['Buckets']['Bucket'] = array($buckets['Buckets']['Bucket']);
    }
    $bucket_container = array();
    if (!empty($buckets['Buckets']['Bucket'])) {
        foreach ($buckets['Buckets']['Bucket'] as $bucket) {
            $bucket_container[$bucket['Name']] = array('name' => $bucket['Name'], 'location' => $bucket['Location']);
        }
    }
    return $bucket_container;
}
Example #8
0
<?php

/**
 * 加载sdk包以及错误代码包
 */
require_once '../sdk.class.php';
$oss_sdk_service = new ALIOSS();
//设置是否打开curl调试模式
$oss_sdk_service->set_debug_mode(false);
//设置开启三级域名,三级域名需要注意,域名不支持一些特殊符号,所以在创建bucket的时候若想使用三级域名,最好不要使用特殊字符
$oss_sdk_service->set_enable_domain_style(DOMAIN_THREE);
/**
 * 测试程序
 * 目前SDK存在一个bug,在文中如果含有-&的时候,会出现找不到相关资源
 */
try {
    /**
     * Service相关操作
     */
    //get_service($oss_sdk_service);
    /**
     * Bucket相关操作
     */
    //create_bucket($oss_sdk_service);
    //delete_bucket($oss_sdk_service);
    //set_bucket_acl($oss_sdk_service);
    //get_bucket_acl($oss_sdk_service);
    //set_bucket_logging($oss_sdk_service);
    //get_bucket_logging($oss_sdk_service);
    //delete_bucket_logging($oss_sdk_service);
    //set_bucket_website($oss_sdk_service);
Example #9
0
function file_remote_upload($filename)
{
    global $_W;
    if (empty($_W['setting']['remote']['type'])) {
        return false;
    }
    if ($_W['setting']['remote']['type'] == '1') {
        require IA_ROOT . '/framework/library/ftp/ftp.php';
        $remoteConfig = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout']);
        $ftp = new Ftp($remoteConfig);
        if (true === $ftp->connect()) {
            $pathinfo = pathinfo($filename);
            $dirs = explode('/', $_W['setting']['remote']['ftp']['dir'] . '/' . $pathinfo['dirname']);
            $dir = '';
            foreach ($dirs as $row) {
                if (!empty($row)) {
                    $dir .= '/' . $row;
                    $ftp->mkdir($dir);
                }
            }
            $desfile = $_W['setting']['remote']['ftp']['dir'] . '/' . $filename;
            if ($ftp->upload(ATTACHMENT_ROOT . '/' . $filename, $desfile)) {
                return true;
            } else {
                return error(1, '远程附件上传失败,请检查配置并重新上传');
            }
        } else {
            return error(1, '远程附件上传失败,请检查配置并重新上传');
        }
    } elseif ($_W['setting']['remote']['type'] == '2') {
        require IA_ROOT . '/framework/library/alioss/sdk.class.php';
        $oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['url'] . '.aliyuncs.com');
        $options = array(ALIOSS::OSS_FILE_UPLOAD => ATTACHMENT_ROOT . '/' . $filename, ALIOSS::OSS_PART_SIZE => 5242880);
        $response = $oss->create_mpu_object($_W['setting']['remote']['alioss']['bucket'], $filename, $options);
        if ($response->status == 200) {
            return true;
        } else {
            return error(1, '远程附件上传失败,请检查配置并重新上传');
        }
    }
}
Example #10
0
function oss_setting_page()
{
    $options = array();
    if ($_POST['bucket']) {
        $options['bucket'] = trim(stripslashes($_POST['bucket']));
    }
    if ($_POST['ak']) {
        $options['ak'] = trim(stripslashes($_POST['ak']));
    }
    if ($_POST['sk']) {
        $options['sk'] = trim(stripslashes($_POST['sk']));
    }
    if ($_POST['host']) {
        $options['host'] = trim(stripslashes($_POST['host']));
    }
    if ($_POST['nothumb']) {
        $options['nothumb'] = isset($_POST['nothumb']) ? 'true' : 'false';
    }
    if ($_POST['nolocalsaving']) {
        $options['nolocalsaving'] = isset($_POST['nolocalsaving']) ? 'true' : 'false';
    }
    if ($_POST['upload_url_path']) {
        //仅用于插件卸载时比较使用
        $options['upload_url_path'] = trim(stripslashes($_POST['upload_url_path']));
    }
    //检查提交的AK/SK是否有管理该bucket的权限
    $flag = 0;
    if ($_POST['bucket'] && $_POST['ak'] && $_POST['sk']) {
        try {
            if (!is_object($aliyun_oss)) {
                $aliyun_oss = new ALIOSS($options['ak'], $options['sk'], $options['host']);
            }
            $oss_option = array(ALIOSS::OSS_CONTENT_TYPE => 'text/xml');
            $response = $aliyun_oss->get_bucket_acl($options['bucket'], $oss_option);
            if ($response->status == 200) {
                $flag = 1;
                if (preg_match('/<Grant>public-read-write<\\/Grant>/i', $response->body) > 0) {
                    $flag = -11;
                } elseif (preg_match('/<Grant>private<\\/Grant>/i', $response->body) > 0) {
                    $flag = -12;
                }
            } elseif ($response->status == 403 && preg_match('/<Endpoint>/i', $response->body) > 0) {
                $flag = -2;
            }
        } catch (Exception $ex) {
            $flag = -1;
        }
    }
    if ($options !== array()) {
        //更新数据库
        update_option('oss_options', $options);
        $upload_path = trim(trim(stripslashes($_POST['upload_path'])), '/');
        $upload_path = $upload_path == '' ? 'wp-content/uploads' : $upload_path;
        update_option('upload_path', $upload_path);
        $upload_url_path = trim(trim(stripslashes($_POST['upload_url_path'])), '/');
        update_option('upload_url_path', $upload_url_path);
        ?>
<div class="updated"><p><strong>设置已保存!
<?php 
        if ($flag == 0) {
            echo '<span style="color:#F00">注意:您的AK/SK没有管理该Bucket的权限,因此不能正常使用!</span>';
        } elseif ($flag == -1) {
            echo '<span style="color:#F00">注意:网络通信错误,未能校验您的AK/SK是否对该bucket是否具有管理权限</span>';
        } elseif ($flag == -11) {
            echo '<span style="color:#F00">注意:该BUCKET现在处于“公开读写”状态,会有安全隐患哦!设置成“公开读”就足够了。</span>';
        } elseif ($flag == -12) {
            echo '<span style="color:#F00">注意:该BUCKET现在处于“私有”状态,不能被其他人访问哦!建议将BUKET权限设置成“公开读”。</span>';
        } elseif ($flag == -2) {
            echo '<span style="color:#F00">注意:该BUCKET的“存储地域”或“HOST主机”可能搞错了,请再次确认下。</span>';
        }
        ?>
</strong></p></div>
<?php 
    }
    $oss_options = get_option('oss_options', TRUE);
    $upload_path = get_option('upload_path');
    $upload_url_path = get_option('upload_url_path');
    $oss_bucket = attribute_escape($oss_options['bucket']);
    $oss_ak = attribute_escape($oss_options['ak']);
    $oss_sk = attribute_escape($oss_options['sk']);
    $oss_host = attribute_escape($oss_options['host']);
    if ($oss_host == null || $oss_host == '') {
        $oss_host = 'oss.aliyuncs.com';
    }
    $oss_nothumb = attribute_escape($oss_options['nothumb']);
    $oss_nothumb = $oss_nothumb == 'true';
    $oss_nolocalsaving = attribute_escape($oss_options['nolocalsaving']);
    $oss_nolocalsaving = $oss_nolocalsaving == 'true';
    ?>
<div class="wrap" style="margin: 10px;">
    <h2>阿里云附件 v2.0 设置</h2>
    <form name="form1" method="post" action="<?php 
    echo wp_nonce_url('./options-general.php?page=' . OSS_BASEFOLDER . '/oss-support.php');
    ?>
">
		<table class="form-table">
			<tr>
				<th><legend>Bucket 设置</legend></th>
				<td>
					<input type="text" name="bucket" value="<?php 
    echo $oss_bucket;
    ?>
" size="50" placeholder="BUCKET"/>
					<p>请先访问 <a href="http://i.aliyun.com/dashboard?type=oss" target="_blank">阿里云存储</a> 创建 <code>bucket</code> ,再填写以上内容。</p>
				</td>
			</tr>
			<tr>
				<th><legend>Access Key</legend></th>
				<td><input type="text" name="ak" value="<?php 
    echo $oss_ak;
    ?>
" size="50" placeholder="Access Key"/></td>
			</tr>
			<tr>
				<th><legend>Secret Key</legend></th>
				<td>
					<input type="text" name="sk" value="<?php 
    echo $oss_sk;
    ?>
" size="50" placeholder="Secret Key"/>
					<p>访问 <a href="https://ak-console.aliyun.com/#/accesskey" target="_blank">阿里云 密钥管理页面</a>,获取 <code>AK/SK</code> 。</p>
				</td>
			</tr>
			<tr>
				<th><legend>HOST主机</legend></th>
				<td>
					<select id="hosts_set" onchange="hostChange()">
						<option value="oss.aliyuncs.com">杭州节点(外网)</option>
						<option value="oss-internal.aliyuncs.com">杭州节点(内网)</option>
						<option value="oss-cn-beijing.aliyuncs.com">北京节点(外网)</option>
						<option value="oss-cn-beijing-internal.aliyuncs.com">北京节点(内网)</option>
						<option value="oss-cn-shenzhen.aliyuncs.com">深圳节点(外网)</option>
						<option value="oss-cn-shenzhen-internal.aliyuncs.com">深圳节点(内网)</option>
						<option value="oss-cn-qingdao.aliyuncs.com">青岛节点(外网)</option>
						<option value="oss-cn-qingdao-internal.aliyuncs.com">青岛节点(内网)</option>
						<option value="oss-cn-hongkong.aliyuncs.com">香港节点(外网)</option>
						<option value="oss-cn-hongkong-internal.aliyuncs.com">香港节点(内网)</option>
						<option value="">自定义设置</option>
					</select>
					<input type="text" id="oss_host" name="host" value="<?php 
    echo $oss_host;
    ?>
" size="29" placeholder="oss.aliyuncs.com" onchange="initSelectSet()"/>
					<p>默认 <code>杭州节点(外网)</code> ,其他节点需要更改。<a href="http://help.aliyun.com/view/11108271_13438690.html" target="_blank">【查看详情】</a></p>
					<script type="text/javascript">
						function initSelectSet() {
							var hostname = document.getElementById("oss_host").value;
							var hostSet = document.getElementById("hosts_set");
							var i = 0;
							for (i = 0; i < hostSet.options.length; i++) {
								if (hostSet.options[i].value == hostname) {
									hostSet.selectedIndex = i;
									break;
								}
							}
							if(i == hostSet.options.length) {
								hostSet.selectedIndex = i-1;
							}
						}
						function hostChange(){
							var host = document.getElementById("hosts_set").value;
							document.getElementById("oss_host").value = host;
						}
						initSelectSet();
					</script>
				</td>
			</tr><tr>
				<th><legend>不上传缩略图</legend></th>
				<td><input type="checkbox" name="nothumb" <?php 
    if ($oss_nothumb) {
        echo 'checked="TRUE"';
    }
    ?>
 /></td>
			</tr><tr>
				<th><legend>不在本地保留备份</legend></th>
				<td><input type="checkbox" name="nolocalsaving" <?php 
    if ($oss_nolocalsaving) {
        echo 'checked="TRUE"';
    }
    ?>
 /></td>
			</tr><tr>
				<th><legend>本地文件夹:</legend></th>
				<td>
					<input type="text" name="upload_path" value="<?php 
    echo $upload_path;
    ?>
" size="50" placeholder="请输入上传文件夹"/>
					<p>附件在服务器上的存储位置,例如: <code>wp-content/uploads</code> (注意不要以“/”开头和结尾),根目录请输入<code>.</code>。</p>
				</td>
			</tr>
			<tr>
				<th><legend>URL前缀:</legend></th>
				<td>
					<input type="text" name="upload_url_path" value="<?php 
    echo $upload_url_path;
    ?>
" size="50" placeholder="请输入URL前缀"/>
					<p><b>注意:</b></p>
					<p>1)URL前缀的格式为 <code>http://{OSS域名}</code> (“本地文件夹”为 <code>.</code> 时),或者 <code>http://{OSS域名}/{本地文件夹}</code> ,“本地文件夹”务必与上面保持一致(结尾无 <code>/</code> )。</p>
					<p>2)OSS中的存放路径(即“文件夹”)与上述 <code>本地文件夹</code> 中定义的路径是相同的(出于方便切换考虑)。</p>
					<p>3)如果需要使用 <code>独立域名</code> ,直接将 <code>{OSS域名}</code> 替换为 <code>独立域名</code> 即可。</p>
				</td>
			</tr>
			<tr>
				<th><legend>更新选项</legend></th>
				<td><input type="submit" name="submit" value="更新" /></td>
			</tr>
		</table>
    </form>
</div>
<?php 
}
Example #11
0
    public function createChromeBak($service)
    {
        $server = $this->getServerByIp($service->server);
        $chrome = <<<STR
{"-confirmDeletion":true,"-downloadInterval":720,"-enableQuickSwitch":false,"-exportLegacyRuleList":true,"-monitorWebRequests":true,"-quickSwitchProfiles":[],"-refreshOnProfileChange":false,"-revertProxyChanges":false,"-showInspectMenu":true,"-startupProfileName":"","schemaVersion":2,"+全局代理":{"bypassList":[{"conditionType":"BypassCondition","pattern":"<local>"}],"color":"#9d9","fallbackProxy":{"host":"{[:server]}","port":{[:port]},"scheme":"socks5"},"name":"全局代理","profileType":"FixedProfile","revision":"14f69ea40f6"},"+智能分流":{"color":"#d497ee","lastUpdate":"","name":"智能分流","pacScript":"","pacUrl":"{[:pacUrl]}","profileType":"PacProfile","revision":"14f6a201b1f"},"+自动切换":{"profileType":"SwitchProfile","name":"自动切换","defaultProfileName":"智能分流","rules":[],"color":"#9ce","revision":"14f6a1fbe64"}}
STR;
        $chrome = str_replace(['{[:server]}', '{[:port]}', '{[:pacUrl]}'], [$server, $service->port, $service->pac], $chrome);
        $filename = substr(md5($server . ":" . $service->port), 8, 16) . '.bak';
        $options = ['content' => $chrome];
        Yii::import('ext.oss_php_sdk_20150819.alioss', true);
        $alioss = new ALIOSS(OSS_ACCESS_ID, OSS_ACCESS_KEY, OSS_ENDPOINT);
        $response = $alioss->upload_file_by_content(OSS_BUCKET, "chrome/" . $filename, $options);
        if ($response->status == 200) {
            return true;
        } else {
            return false;
        }
    }
Example #12
0
 public function authorize()
 {
     global $_G, $_GET, $clouds;
     if (empty($_G['uid'])) {
         dsetcookie('_refer', rawurlencode(BASESCRIPT . '?mod=connect&op=oauth&bz=ALIOSS'));
         showmessage('to_login', '', array(), array('showmsg' => true, 'login' => 1));
     }
     if (submitcheck('alisubmit')) {
         $access_id = $_GET['access_id'];
         $access_key = $_GET['access_key'];
         $hostname = $_GET['hostname'];
         $bucket = $_GET['bucket'];
         if (!$access_id || !$access_key) {
             showmessage('please input aliyun Access Key ID and Access Key Secret', dreferer());
         }
         if (!$bucket || !$hostname) {
             showmessage('请选择bucket和节点地址', dreferer());
         }
         require_once DZZ_ROOT . './core/api/oss_sdk/sdk.class.php';
         $oss = new ALIOSS($access_id, $access_key, $hostname);
         try {
             $response = $oss->list_bucket();
             if (!$response->isOK()) {
                 showmessage('aliyun Access Key ID or Access Key Secret error', dreferer());
             }
         } catch (Exception $e) {
             showmessage($e->getMessage(), dreferer());
         }
         $type = 'ALIOSS';
         $uid = defined('IN_ADMIN') ? 0 : $_G['uid'];
         $setarr = array('uid' => $uid, 'access_id' => $access_id, 'access_key' => authcode($access_key, 'ENCODE', $type), 'bz' => $type, 'bucket' => $bucket, 'hostname' => $hostname, 'dateline' => TIMESTAMP);
         if ($id = DB::result_first("select id from " . DB::table(self::T) . " where uid='{$uid}' and access_id='{$access_id}' and bucket='{$bucket}'")) {
             DB::update(self::T, $setarr, "id ='{$id}'");
         } else {
             $id = DB::insert(self::T, $setarr, 1);
         }
         if (defined('IN_ADMIN')) {
             $setarr = array('name' => $clouds[$type]['name'] . ':' . ($bucket ? $bucket : cutstr($access_id, 4, '')), 'bz' => $type, 'isdefault' => 0, 'dname' => self::T, 'did' => $id, 'dateline' => TIMESTAMP);
             if (!DB::result_first("select COUNT(*) from %t where did=%d and dname=%s ", array('local_storage', $id, self::T))) {
                 C::t('local_storage')->insert($setarr);
             }
             showmessage('do_success', BASESCRIPT . '?mod=cloud&op=space');
         } else {
             showmessage('do_success', BASESCRIPT . '?mod=connect');
         }
     } else {
         include template('oauth_ALIOSS');
     }
 }
Example #13
0
 /**
  * 上传
  *
  * @param	intval	$uid	uid	用户id
  * @param	array	$info	ci 文件上传成功返回数据
  * @return	array
  */
 public function upload($uid, $info)
 {
     $_ext = strtolower(substr($info['file_ext'], 1));
     $author = $this->_get_member_name($uid);
     $content = file_get_contents($info['full_path']);
     // 入库附件
     $this->db->replace('attachment', array('uid' => $uid, 'author' => $author, 'siteid' => $this->siteid, 'tableid' => 0, 'related' => '', 'fileext' => $_ext, 'filemd5' => $content ? md5($content) : 0, 'download' => 0, 'filesize' => $info['file_size'] * 1024));
     $id = $this->db->insert_id();
     unset($content);
     // 入库失败,返回错误且删除附件
     if (!$id) {
         @unlink($info['full_path']);
         return lang('m-145');
     }
     $remote = 0;
     $attachment = $file = substr($info['full_path'], strlen(FCPATH));
     // 附件配置信息
     $config = $this->ci->get_cache('siteinfo', SITE_ID, 'remote', SITE_ATTACH_REMOTE);
     // 远程附件模式
     if ($config && $config['SITE_ATTACH_EXTS'] && ($_exts = explode(',', $config['SITE_ATTACH_EXTS'])) && in_array($_ext, $_exts)) {
         // 根据模式来存储
         set_time_limit(0);
         if (SITE_ATTACH_REMOTE == 1) {
             // ftp附件模式
             $this->load->library('ftp');
             if ($this->ftp->connect(array('port' => $config['SITE_ATTACH_PORT'], 'debug' => FALSE, 'passive' => $config['SITE_ATTACH_PASV'], 'hostname' => $config['SITE_ATTACH_HOST'], 'username' => $config['SITE_ATTACH_USERNAME'], 'password' => $config['SITE_ATTACH_PASSWORD']))) {
                 // 连接ftp成功
                 $dir = basename(dirname($info['full_path'])) . '/';
                 $file = basename($info['full_path']);
                 $path = $config['SITE_ATTACH_PATH'] . '/' . $dir;
                 $this->ftp->mkdir($path);
                 if ($this->ftp->upload($info['full_path'], $path . $file, $config['SITE_ATTACH_MODE'], 0775)) {
                     $remote = 1;
                     $attachment = $dir . $file;
                     $file = $config['SITE_ATTACH_URL'] . '/' . $attachment;
                     unlink($info['full_path']);
                 }
                 $this->ftp->close();
             } else {
                 log_message('error', '远程附件ftp模式:ftp连接失败');
             }
         } elseif (SITE_ATTACH_REMOTE == 2) {
             // 百度云存储模式
             $file = basename(dirname($info['full_path'])) . '/' . basename($info['full_path']);
             require_once FCPATH . 'omooo/libraries/BaiduBCS/bcs.class.php';
             $bcs = new BaiduBCS($config['ak'], $config['sk'], $config['host']);
             $opt = array();
             $opt['acl'] = BaiduBCS::BCS_SDK_ACL_TYPE_PUBLIC_WRITE;
             $opt['curlopts'] = array(CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 1800);
             $response = $bcs->create_object($config['bucket'], '/' . $file, $info['full_path'], $opt);
             if ($response->status == 200) {
                 $remote = 2;
                 $attachment = $file;
                 $file = $config['SITE_ATTACH_URL'] . '/' . $attachment;
                 unlink($info['full_path']);
             } else {
                 log_message('error', '远程附件百度云存储失败');
             }
         } elseif (SITE_ATTACH_REMOTE == 3) {
             // 阿里云存储模式
             $file = basename(dirname($info['full_path'])) . '/' . basename($info['full_path']);
             require_once FCPATH . 'omooo/libraries/AliyunOSS/sdk.class.php';
             $oss = new ALIOSS($config['id'], $config['secret'], $config['host']);
             $oss->set_debug_mode(FALSE);
             $response = $oss->upload_file_by_file($config['bucket'], $file, $info['full_path']);
             if ($response->status == 200) {
                 $remote = 3;
                 $attachment = $file;
                 $file = $config['SITE_ATTACH_URL'] . '/' . $attachment;
                 unlink($info['full_path']);
             } else {
                 log_message('error', '远程附件阿里云存储模式:' . $response->body);
             }
         }
     }
     // 非远程附件补全本地地址
     if (!$remote) {
         $file = SITE_URL . $file;
     }
     $pos = strrpos($info['client_name'], '.');
     $filename = strpos($info['client_name'], 'http://') === 0 ? trim(strrchr($info['client_name'], '/'), '/') : $info['client_name'];
     $filename = $pos ? substr($filename, 0, $pos) : $filename;
     // 增加至未使用附件表
     $this->db->replace('attachment_unused', array('id' => $id, 'uid' => $uid, 'author' => $author, 'siteid' => $this->siteid, 'remote' => $remote, 'fileext' => $_ext, 'filename' => $filename, 'filesize' => $info['file_size'] * 1024, 'inputtime' => SYS_TIME, 'attachment' => $attachment, 'attachinfo' => ''));
     return array($id, $file, $_ext);
 }
Example #14
0
 /**
  * 删除文件
  *
  * @access public
  * @param array $content 文件相关信息
  * @return string
  */
 public static function deleteHandle(array $content)
 {
     $options = Typecho_Widget::widget('Widget_Options');
     $access_id = $options->plugin('AliUpload')->access_id;
     $access_key = $options->plugin('AliUpload')->access_key;
     $bucket = $options->plugin('AliUpload')->bucket;
     $oss_service = new ALIOSS($access_id, $access_key);
     $response = $oss_service->delete_object($bucket, $content['attachment']->path);
     return $response->isOk();
 }
Example #15
0
 function syn_to_remote_file_server($url)
 {
     if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") {
         if ($GLOBALS['distribution_cfg']['OSS_TYPE'] == "ES_FILE") {
             $pathinfo = pathinfo($url);
             $file = $pathinfo['basename'];
             $dir = $pathinfo['dirname'];
             $dir = str_replace("public/", "", $dir);
             $filefull = SITE_DOMAIN . APP_ROOT . "/public/" . $dir . "/" . $file;
             $syn_url = $GLOBALS['distribution_cfg']['OSS_DOMAIN'] . "/es_file.php?username="******"&password="******"&file=" . $filefull . "&path=" . $dir . "/&name=" . $file . "&act=0";
             @file_get_contents($syn_url);
         } elseif ($GLOBALS['distribution_cfg']['OSS_TYPE'] == "ALI_OSS") {
             $pathinfo = pathinfo($url);
             $file = $pathinfo['basename'];
             $dir = $pathinfo['dirname'];
             $ali_oss_sdk = APP_ROOT_PATH . "system/alioss/sdk.class.php";
             if (file_exists($ali_oss_sdk)) {
                 require_once $ali_oss_sdk;
                 if (class_exists("ALIOSS")) {
                     $oss_sdk_service = new ALIOSS();
                     $oss_sdk_service->set_debug_mode(FALSE);
                     $bucket = $GLOBALS['distribution_cfg']['OSS_BUCKET_NAME'];
                     $object = $dir . "/" . $file;
                     $file_path = APP_ROOT_PATH . $dir . "/" . $file;
                     $oss_sdk_service->upload_file_by_file($bucket, $object, $file_path);
                 }
             }
         }
     }
 }
Example #16
0
/**
 * @param $upload
 */
function CloudStorage_Del(&$upload)
{
    global $zbp;
    $bucket = $zbp->Config('CloudStorage')->CS_Bucket;
    switch ($upload->Metas->CS_Tpye) {
        case '1':
            define('OSS_ACCESS_ID', $zbp->Config('CloudStorage')->CS_Ali_KeyID);
            //ACCESS_ID
            define('OSS_ACCESS_KEY', $zbp->Config('CloudStorage')->CS_Ali_KeySecret);
            //ACCESS_KEY
            require_once dirname(__FILE__) . '/api/oss/sdk.class.php';
            $os_service = new ALIOSS();
            $os_service->set_debug_mode(FALSE);
            $object = str_replace("http://" . $bucket . ".oss.aliyuncs.com/", '', $upload->Metas->CS_URL);
            $os_service->delete_object($bucket, $object);
            break;
        case '2':
            require_once dirname(__FILE__) . '/api/qiniu/io.php';
            require_once dirname(__FILE__) . '/api/qiniu/rs.php';
            $accessKey = $zbp->Config('CloudStorage')->CS_QNiu_KeyID;
            $secretKey = $zbp->Config('CloudStorage')->CS_QNiu_KeySecret;
            Qiniu_SetKeys($accessKey, $secretKey);
            $client = new Qiniu_MacHttpClient(null);
            $object = str_replace("http://" . $bucket . ".u.qiniudn.com/", '', $upload->Metas->CS_URL);
            Qiniu_RS_Delete($client, $bucket, $object);
            break;
        case '3':
            define('BCS_AK', $zbp->Config('CloudStorage')->CS_Baidu_KeyID);
            //AK 公钥
            define('BCS_SK', $zbp->Config('CloudStorage')->CS_Baidu_KeySecret);
            //SK 私钥
            require_once dirname(__FILE__) . '/api/bcs/bcs.class.php';
            $baidu_bcs = new BaiduBCS();
            $object = str_replace("http://bcs.duapp.com/" . $bucket, '', $upload->Metas->CS_URL);
            $baidu_bcs->delete_object($bucket, $object);
            break;
        default:
            break;
    }
    return true;
    $GLOBALS['Filter_Plugin_Upload_DelFile']['CloudStorage_Del'] = PLUGIN_EXITSIGNAL_RETURN;
}
Example #17
0
 public static function uploadFile($file, $content = null)
 {
     // 获取上传文件
     if (empty($file['name'])) {
         return false;
     }
     $option = self::getConfig();
     if (!isset($option->accessid)) {
         return false;
     }
     self::initSDK();
     $obj = new ALIOSS($option->accessid, $option->accesskey, $option->endpoint);
     // 校验扩展名
     $part = explode('.', $file['name']);
     $ext = ($length = count($part)) > 1 ? strtolower($part[$length - 1]) : '';
     if (!Widget_Upload::checkFileType($ext)) {
         return false;
     }
     // 保存位置
     $savename = str_replace(array('{year}', '{month}', '{day}'), array(date('Y'), date('m'), date('d')), ltrim(self::isImage($ext) ? $option->savepath : $option->nonimg_savepath, '/')) . sprintf('%u', crc32(uniqid())) . '.' . $ext;
     $response = $obj->upload_file_by_file($option->bucket, $savename, $file['tmp_name']);
     if ($response->status === 200) {
         return array('name' => $file['name'], 'path' => $savename, 'size' => $file['size'], 'type' => $ext, 'mime' => Typecho_Common::mimeContentType($savename));
     }
     return false;
 }
Example #18
0
 function ossdel($file_path)
 {
     require_once CSCMSPATH . 'uploads/oss/sdk.class.php';
     if (substr($file_path, 0, 1) == '/') {
         $file_path = substr($file_path, 1);
     }
     $obj = new ALIOSS();
     $response = $obj->delete_object(BUCKET, $file_path);
     if ($response->status == 200) {
         return true;
     } else {
         return false;
     }
 }
Example #19
0
     if (empty($buckets[$bucket])) {
         message(error(-1, '填写的bucket错误,请重新填写'), '', 'ajax');
     }
 }
 $ossurl = $buckets[$bucket]['location'] . '.aliyuncs.com';
 if (!empty($_GPC['url'])) {
     if (!strexists($_GPC['url'], 'http://') && !strexists($_GPC['url'], 'https://')) {
         $url = 'http://' . trim($_GPC['url']);
     } else {
         $url = trim($_GPC['url']);
     }
     $url = trim($url, '/') . '/';
 } else {
     $url = 'http://' . $bucket . '.' . $buckets[$bucket]['location'] . '.aliyuncs.com/';
 }
 $oss = new ALIOSS($_GPC['key'], $_GPC['secret'], $ossurl);
 $filename = 'MicroEngine.ico';
 $options = array(ALIOSS::OSS_FILE_UPLOAD => ATTACHMENT_ROOT . 'images/global/' . $filename, ALIOSS::OSS_PART_SIZE => 5242880);
 $response = $oss->create_mpu_object($bucket, $filename, $options);
 if ($response->status == 200) {
     load()->func('communication');
     $response = ihttp_get($url . $filename);
     if (is_error($response)) {
         message(error(-1, '配置失败,阿里云访问url错误'), '', 'ajax');
     }
     if (intval($response['code']) != 200) {
         message(error(-1, '配置失败,阿里云访问url错误,请保证bucket为公共读取的'), '', 'ajax');
     }
     $image = getimagesizefromstring($response['content']);
     if (!empty($image) && strexists($image['mime'], 'image')) {
         message(error(0, '配置成功'), '', 'ajax');
Example #20
0
<?php

/**
 * 加载sdk包以及错误代码包
 */
require_once '../sdk.class.php';
$oss_sdk_service = new ALIOSS();
//设置是否打开curl调试模式
$oss_sdk_service->set_debug_mode(FALSE);
//设置开启三级域名,三级域名需要注意,域名不支持一些特殊符号,所以在创建bucket的时候若想使用三级域名,最好不要使用特殊字符
//$oss_sdk_service->set_enable_domain_style(TRUE);
/**
 * 测试程序
 * 目前SDK存在一个bug,在文中如果含有-&的时候,会出现找不到相关资源
 */
try {
    /**
     * Service相关操作
     */
    //get_service($oss_sdk_service);
    /**
     * Bucket相关操作
     */
    //create_bucket($oss_sdk_service);
    //delete_bucket($oss_sdk_service);
    //set_bucket_acl($oss_sdk_service);
    //get_bucket_acl($oss_sdk_service);
    //set_bucket_logging($oss_sdk_service);
    //get_bucket_logging($oss_sdk_service);
    //delete_bucket_logging($oss_sdk_service);
    //set_bucket_website($oss_sdk_service);
Example #21
0
{
    if ($dir = opendir($path)) {
        while ($file = readdir($dir)) {
            $check = is_dir($path . $file);
            if (!$check) {
                if (!preg_match("/_(\\d+)x(\\d+)/i", $file, $matches)) {
                    //同步
                    $file_dir = str_replace(APP_ROOT_PATH, "", $path);
                    $object = $file_dir . $file;
                    $file_path = $path . $file;
                    $service->upload_file_by_file($bucket, $object, $file_path);
                }
            } else {
                if ($file != '.' && $file != '..') {
                    syn_path($service, $bucket, $path . $file . "/");
                }
            }
        }
        closedir($dir);
    }
}
if ($GLOBALS['distribution_cfg']['OSS_TYPE'] == "ALI_OSS") {
    require_once APP_ROOT_PATH . "system/alioss/sdk.class.php";
    $oss_sdk_service = new ALIOSS();
    //设置是否打开curl调试模式
    $oss_sdk_service->set_debug_mode(FALSE);
    $bucket = $GLOBALS['distribution_cfg']['OSS_BUCKET_NAME'];
    foreach ($GLOBALS['paths'] as $path) {
        syn_path($oss_sdk_service, $bucket, APP_ROOT_PATH . $path);
    }
}
Example #22
0
 function ftp_get($file, $path)
 {
     $obj = new ALIOSS();
     $obj->set_host_name($this->hostname, $this->port);
     $obj->set_debug_mode(FALSE);
     $bucket = $this->bucket;
     $file = jishigou_oss::clear($file);
     $path = jishigou_oss::clear($path);
     $options = array(ALIOSS::OSS_FILE_DOWNLOAD => $path);
     $response = $obj->get_object($bucket, $file, $options);
     $rt = jishigou_oss::status($response);
     return $rt == '2' ? 1 : 0;
 }
Example #23
0
<?php

/**
 * 加载sdk包以及错误代码包
 */
require_once '../sdk.class.php';
$oss_sdk_service = new ALIOSS();
//设置是否打开curl调试模式
$oss_sdk_service->set_debug_mode(FALSE);
//设置开启三级域名,三级域名需要注意,域名不支持一些特殊符号,所以在创建bucket的时候若想使用三级域名,最好不要使用特殊字符
//$oss_sdk_service->set_enable_domain_style(TRUE);
/**
 * 测试程序
 * 目前SDK存在一个bug,在文中如果含有-&的时候,会出现找不到相关资源
 */
try {
    /**
     * Service相关操作
     */
    //get_service($oss_sdk_service);
    /**
     * Bucket相关操作
     */
    //create_bucket($oss_sdk_service);
    //delete_bucket($oss_sdk_service);
    //set_bucket_acl($oss_sdk_service);
    //get_bucket_acl($oss_sdk_service);
    //set_bucket_logging($oss_sdk_service);
    //get_bucket_logging($oss_sdk_service);
    //delete_bucket_logging($oss_sdk_service);
    //set_bucket_website($oss_sdk_service);
Example #24
0
 /**
  * 上传文件的主处理方法
  * @return mixed
  */
 private function upFile()
 {
     $file = $this->file = $_FILES[$this->fileField];
     if (!$file) {
         $this->stateInfo = $this->getStateInfo("ERROR_FILE_NOT_FOUND");
         return;
     }
     if ($this->file['error']) {
         $this->stateInfo = $this->getStateInfo($file['error']);
         return;
     } else {
         if (!file_exists($file['tmp_name'])) {
             $this->stateInfo = $this->getStateInfo("ERROR_TMP_FILE_NOT_FOUND");
             return;
         } else {
             if (!is_uploaded_file($file['tmp_name'])) {
                 $this->stateInfo = $this->getStateInfo("ERROR_TMPFILE");
                 return;
             }
         }
     }
     $this->oriName = $file['name'];
     $this->fileSize = $file['size'];
     $this->fileType = $this->getFileExt();
     $this->fullName = $this->getFullName();
     $this->filePath = $this->getFilePath();
     $this->fileName = $this->getFileName();
     $dirname = dirname($this->filePath);
     //检查文件大小是否超出限制
     if (!$this->checkSize()) {
         $this->stateInfo = $this->getStateInfo("ERROR_SIZE_EXCEED");
         return;
     }
     //检查是否不允许的文件格式
     if (!$this->checkType()) {
         $this->stateInfo = $this->getStateInfo("ERROR_TYPE_NOT_ALLOWED");
         return;
     }
     //移动文件
     $SCRIPT_FILENAME = $_SERVER["SCRIPT_FILENAME"];
     $SCRIPT_FILENAME = explode('webroot', $SCRIPT_FILENAME);
     $this->filePath = 'activitys/' . $_REQUEST['activityId'] . '/' . $this->fileName;
     include $SCRIPT_FILENAME[0] . 'webroot/aliyun2/sdk.class.php';
     $file = file_get_contents($file['tmp_name']);
     $uploadFileoptions = array('content' => $file, 'length' => $this->fileSize);
     $oss_sdk_service = new ALIOSS();
     $rest = $oss_sdk_service->upload_file_by_content("open-edit", $this->filePath, $uploadFileoptions);
     $thumbpath = $rest->header['x-oss-request-url'];
     $this->fullName = str_replace('oss-cn-hangzhou.aliyuncs.com/open-edit', 'cdn.open.easytee.me', $thumbpath);
     $this->stateInfo = 'SUCCESS';
 }
 protected function publish($dat = [])
 {
     $id = (int) $dat['id'];
     $htm = '';
     if ($id) {
         $dat = D(CONTROLLER_NAME)->complete_fields($dat);
         $this->data = ['item' => $dat];
         layout(false);
         $htm = $this->fetch('view');
         $fnm = 'article/content/' . $id . '.html';
         import('Org.AliyunOss.sdk');
         $oss = new \ALIOSS();
         $oss->delete_object('cjstatic', $fnm);
         $ret = $oss->upload_file_by_content('cjstatic', $fnm, ['content' => $dat['content'], 'Content-Encoding' => 'UTF-8', 'Expires' => date('Y-m-d H:i:s', strtotime('1 days'))]);
     }
     return $dat;
 }
Example #26
0
function oss_make_dir($obj_dir)
{
    include_once PHPDISK_ROOT . 'includes/oss/sdk.class.php';
    $obj = new ALIOSS();
    $obj->set_debug_mode(false);
    $bucket = get_oss_info('oss_bucket');
    $response = $obj->create_object_dir($bucket, get_oss_info('id') . '/' . $obj_dir);
    //_format($response);
    return $response->status == 200 ? true : false;
}
Example #27
0
function file_remote_delete($file)
{
    global $_W;
    if (empty($file)) {
        return true;
    }
    if ($_W['setting']['remote']['type'] == '1') {
        require IA_ROOT . '/framework/library/ftp/ftp.php';
        $ftp_config = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout'], 'rootdir' => $_W['setting']['remote']['ftp']['dir']);
        $ftp = new Ftp($ftp_config);
        if (true === $ftp->connect()) {
            if ($ftp->delete_file($file)) {
                return true;
            } else {
                return error(1, '删除附件失败,请检查配置并重新删除');
            }
        } else {
            return error(1, '删除附件失败,请检查配置并重新删除');
        }
    } elseif ($_W['setting']['remote']['type'] == '2') {
        require IA_ROOT . '/framework/library/alioss/sdk.class.php';
        $oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['ossurl']);
        $response = $oss->delete_object($_W['setting']['remote']['alioss']['bucket'], $file);
        if ($response->status == 204) {
            return true;
        } else {
            return error(1, '删除oss远程文件失败');
        }
    }
    return true;
}
Example #28
0
function file_remote_delete($file)
{
    global $_W;
    if (empty($file)) {
        return true;
    }
    if ($_W['setting']['remote']['type'] == '1') {
        require_once IA_ROOT . '/framework/library/ftp/ftp.php';
        $ftp_config = array('hostname' => $_W['setting']['remote']['ftp']['host'], 'username' => $_W['setting']['remote']['ftp']['username'], 'password' => $_W['setting']['remote']['ftp']['password'], 'port' => $_W['setting']['remote']['ftp']['port'], 'ssl' => $_W['setting']['remote']['ftp']['ssl'], 'passive' => $_W['setting']['remote']['ftp']['pasv'], 'timeout' => $_W['setting']['remote']['ftp']['timeout'], 'rootdir' => $_W['setting']['remote']['ftp']['dir']);
        $ftp = new Ftp($ftp_config);
        if (true === $ftp->connect()) {
            if ($ftp->delete_file($file)) {
                return true;
            } else {
                return error(1, '删除附件失败,请检查配置并重新删除');
            }
        } else {
            return error(1, '删除附件失败,请检查配置并重新删除');
        }
    } elseif ($_W['setting']['remote']['type'] == '2') {
        require_once IA_ROOT . '/framework/library/alioss/sdk.class.php';
        $oss = new ALIOSS($_W['setting']['remote']['alioss']['key'], $_W['setting']['remote']['alioss']['secret'], $_W['setting']['remote']['alioss']['ossurl']);
        $response = $oss->delete_object($_W['setting']['remote']['alioss']['bucket'], $file);
        if ($response->status == 204) {
            return true;
        } else {
            return error(1, '删除oss远程文件失败');
        }
    } elseif ($_W['setting']['remote']['type'] == '3') {
        require_once IA_ROOT . '/framework/library/qiniu/autoload.php';
        $auth = new Qiniu\Auth($_W['setting']['remote']['qiniu']['accesskey'], $_W['setting']['remote']['qiniu']['secretkey']);
        $bucketMgr = new Qiniu\Storage\BucketManager($auth);
        $error = $bucketMgr->delete($_W['setting']['remote']['qiniu']['bucket'], $file);
        if ($error instanceof Qiniu\Http\Error) {
            if ($error->code() == 612) {
                return true;
            }
            return error(1, '删除七牛远程文件失败');
        } else {
            return true;
        }
    }
    return true;
}
Example #29
0
 public function aliyuntest()
 {
     $id = $this->input->get('id');
     $host = $this->input->get('host');
     $rurl = $this->input->get('rurl');
     $secret = $this->input->get('secret');
     $bucket = $this->input->get('bucket');
     if (!$id || !$host || !$secret || !$bucket) {
         exit(lang('035'));
     }
     if (!$rurl) {
         exit(lang('199'));
     }
     require_once FCPATH . 'omooo/libraries/AliyunOSS/sdk.class.php';
     $oss = new ALIOSS($id, $secret, $host);
     $response = $oss->upload_file_by_file($bucket, 'test.txt', FCPATH . 'index.php');
     if ($response->status == 200) {
         $oss->delete_object($bucket, 'test.txt');
         if (strpos(dr_catcher_data($rurl . '/test.txt'), 'omooo.com') === FALSE) {
             exit(lang('200'));
         }
         exit('ok');
     } else {
         exit($response->body);
     }
 }
Example #30
0
<?php

require_once './demo/tutorial.php';
require_once './sdk.class.php';
$oss_sdk_service = new ALIOSS();
//设置是否打开curl调试模式
$oss_sdk_service->set_debug_mode(FALSE);
//var_dump($oss_sdk_service);
$bucket = 'qtyd';
$host = "D:\\xampp\\htdocs\\www.zjqttz.comv1\\www\\";
$floder = array("D:\\xampp\\htdocs\\www.zjqttz.comv1\\www\\upload", "D:\\xampp\\htdocs\\www.zjqttz.comv1\\www\\plupload");
//遍历目录
set_time_limit(0);
// define('M_PATH',$floder);  //设置监控的目录,当前目录为'.',上一级目录为'..',也可以设置绝对路径,后面不要加斜杠
define('M_LOG', './m.log');
//设置存储log的路径,可以放置在任意位置
define('M_FILE', './f.log');
//待上传的文件列表
$filesarr = array();
//待更新文件
if (file_exists(M_FILE)) {
    _log('m file is exists.');
    $filesarr = unserialize(file_get_contents(M_FILE));
    foreach ($filesarr as $key => $file) {
        _log('m file :' . $file);
        //上传动作:
        $object = str_replace($host, "", $file);
        $file_path = $file;
        $response = $oss_sdk_service->upload_file_by_file($bucket, $object, $file_path);
        _format($response);
        unset($filesarr[$key]);