作者 刘锟

upload_remote

... ... @@ -73,7 +73,7 @@ class ProjectImport extends Command
$project = ProjectServer::useProject($task->project_id);
if ($project) {
foreach ($line_of_text as $k => $v) {
if ($k > 0 && $v) {
if ($k > 0 && $v[0]) {
$total_count += 1;
if ($task->type == ImportTask::TYPE_NEWS) {
if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) {
... ...
... ... @@ -270,7 +270,7 @@ class NewsLogic extends BaseLogic
public function importNews($project_id, $user_id, $data)
{
$category_id = '';
if (!empty($data[2])) {
if ($data[2]) {
//处理分类
$newsCategoryLogic = new NewsCategoryLogic();
$category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
... ... @@ -282,12 +282,12 @@ class NewsLogic extends BaseLogic
[
'name' => $data[0],
'category_id' => $category_id,
'text' => $data[4],
'remark' => $data[3],
'text' => $data[4] ?? '',
'remark' => $data[3] ?? '',
'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '',
'seo_title' => $data[6],
'seo_keywords' => $data[7],
'seo_description' => $data[8],
'seo_title' => $data[6] ?? '',
'seo_keywords' => $data[7] ?? '',
'seo_description' => $data[8] ?? '',
'project_id' => $project_id,
'operator_id' => $user_id,
'create_id' => $user_id
... ...
... ... @@ -95,10 +95,11 @@ class CosService
'Key' => $key,
'Body' => fopen($file_url, 'r'),
]);
return $key;
}catch (\Exception $e){
LogUtils::error('uploadRemote error', $e->getMessage());
}
return $key;
}
}
... ...