網(wǎng)站設(shè)計(jì)日志seo搜索引擎優(yōu)化策略
背景
? ? ? ?項(xiàng)目的實(shí)際需求中既要用到阿里云oss產(chǎn)品又用到阿里云點(diǎn)播系統(tǒng),實(shí)現(xiàn)完美的統(tǒng)一。設(shè)置兩個(gè)地址downUrl,thirdCode。分別代表阿里云oss上傳路徑和阿里云點(diǎn)播系統(tǒng)vId。
實(shí)現(xiàn)
? ? ? ?默認(rèn)框架你已經(jīng)集成好阿里云oss集成工作,前端html頁面實(shí)現(xiàn)
<form id="edit-form" class="form-horizontal form-ajax" role="form" data-toggle="validator" method="POST" action=""><input name="row[id]" type="hidden" value="{$row.id}" ><div class="form-group" style="display: none"><label for="c-title" class="control-label col-xs-12 col-sm-2">{:__('作者')}:</label><div class="col-xs-12 col-sm-8"><input id="c-title" data-rule="" class="form-control" name="row[author]" type="text" value="{$row.author|htmlentities}" placeholder="請(qǐng)輸作者"></div></div><div class="form-group"><label class="control-label col-xs-12 col-sm-2">{:__('音視頻')}:</label><div class="col-xs-12 col-sm-8"><div class="input-group"><input id="c-downurl" data-rule="" class="form-control" size="255" name="row[downurl]" type="text" value="{$row.downurl}"><div class="input-group-addon no-border no-padding"><span><button type="button" id="plupload-downurl" class="btn btn-danger plupload" data-input-id="c-downurl" data-mimetype="*" data-multiple="false" data-preview-id="p-downurl"><i class="fa fa-upload"></i> {:__('Upload')}</button></span><span><button type="button" id="fachoose-downurl" class="btn btn-primary fachoose" data-input-id="c-downurl" data-mimetype="*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span></div><span class="msg-box n-right" for="c-downurl"></span></div><ul class="row list-inline plupload-preview" id="p-downurl"></ul></div></div><div class="form-group layer-footer"><label class="control-label col-xs-12 col-sm-2"></label><div class="col-xs-12 col-sm-8"><button type="submit" class="btn btn-success btn-embossed" id="submit">{:__('OK')}</button><button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button></div></div>
</form>
table.bootstrapTable({url: $.fn.bootstrapTable.defaults.extend.index_url,showToggle: false,showColumns: false,showExport: false,//commonSearch: false,search:false,fixedColumns: true,fixedRightNumber: 1,columns: [[{checkbox: true},{field: 'id', title: __('序號(hào)'),operate:false},{field: 'category.name', title: __('格式'),operate:false,formatter:Table.api.formatter.label},{field: 'categoryId', title: __('格式'),visible: false,searchList: $.getJSON("ajax/filecate")},{field: 'title',title: __('標(biāo)題'),operate:'LIKE',cellStyle: {css: {"max-width": "500px","white-space":"nowrap","overflow":"hidden","text-overflow":"ellipsis"}}},{field: 'secondId', title: __('分類'), visible: false,searchList: $.getJSON("ajax/schooldata")},{field: 'thumb', title: __('縮略圖'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},{field: 'third_code', title: __('三方平臺(tái)'),operate: false},{field: 'createtime', title: __('提交時(shí)間'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'updatetime', title: __('更新時(shí)間'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true}, {field: 'status', title: __('Status'), formatter: Controller.api.formatter.station, searchList: {0: __('草稿'), 1: __('發(fā)布')}},{field: 'operate', title: __('Operate'), buttons: [{name: '視頻轉(zhuǎn)碼',text: '',title: __('轉(zhuǎn)碼'),classname: 'btn btn-xs btn-success btn-view btn-dialog',icon: 'fa fa-trademark',url: 'school/data/transfer?id={ids}',refresh:true ,visible: function (row) {//返回true時(shí)按鈕顯示,返回false隱藏if(row.categoryId===232){if(row.third_plat==0||!row.third_plat) return true;}return false}},{name: 'detail',text: '', title: '編輯',icon: 'fa fa-pencil',classname: 'btn btn-xs btn-info btn-addtabs',url: 'school/data/edit'}], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}]]});
使用ajax異常實(shí)現(xiàn)上傳
public function uploadV(){Config::set('default_return_type', 'json');$attachment = null;$res="";//默認(rèn)普通上傳文件$file = $this->request->post('url');//print_r($file->getMime());//print_r($file->getFilename());//print_r($file->getRealPath());require_once APP_PATH. DIRECTORY_SEPARATOR . 'voduploadsdk' . DIRECTORY_SEPARATOR . 'Autoloader.php';try {//$upload = new Upload($file);//print_r($upload->getFile());//$attachment = $upload->upload();$apiRegionId = 'cn-beijing';$uploader = new \AliyunVodUploader(Config::get('aliVod.accessKeyId'), Config::get('aliVod.accessKeySecret'), $apiRegionId);$fileURL="http://xxxxxx".$file;$uploadVideoRequest = new \UploadVideoRequest($fileURL, "課程");$res = $uploader->uploadWebVideo($uploadVideoRequest);if ($res) { // 根據(jù)你的邏輯,可能需要檢查 $res 是否表示成功return json(['status' => 'success', 'data' => $res]);} else {// 處理 $res 為空或失敗的情況return json(['status' => 'error', 'message' => '上傳失敗,未獲取到有效響應(yīng)']);}} catch (\Exception $e) {return json(['status' => 'error', 'message' => $e->getMessage()]);}}
可以完美完成。本功能實(shí)現(xiàn)大概用了一周,遇到很多問題,包括sdk引入層級(jí)問題,ajax異步格式返回等待