refactor: 数据迁移命令
This commit is contained in:
@@ -38,15 +38,15 @@ class DataMigration extends Command
|
|||||||
// $this->productCategory();
|
// $this->productCategory();
|
||||||
|
|
||||||
// 迁移文章
|
// 迁移文章
|
||||||
$this->migrateArticle([
|
// $this->migrateArticle([
|
||||||
1 => 2,
|
// 1 => 2,
|
||||||
2 => 3,
|
// 2 => 3,
|
||||||
33 => 4,
|
// 33 => 4,
|
||||||
36 => 5,
|
// 36 => 5,
|
||||||
16 => 7,
|
// 16 => 7,
|
||||||
31 => 8,
|
// 31 => 8,
|
||||||
32 => 9
|
// 32 => 9
|
||||||
]);
|
// ]);
|
||||||
|
|
||||||
// 迁移faq
|
// 迁移faq
|
||||||
// $this->migrateFaq();
|
// $this->migrateFaq();
|
||||||
@@ -258,11 +258,18 @@ class UploadMannager
|
|||||||
}
|
}
|
||||||
$url = self::DOWNLOAD_BASE_API . \think\helper\Str::substr($file_name, mb_strpos($file_name, $need) + mb_strlen($need));
|
$url = self::DOWNLOAD_BASE_API . \think\helper\Str::substr($file_name, mb_strpos($file_name, $need) + mb_strlen($need));
|
||||||
} else {
|
} else {
|
||||||
$url = self::DOWNLOAD_BASE_API . $file_name;
|
$url = self::DOWNLOAD_BASE_API . str_replace(" ", "%20", $file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = self::DOWNLOAD_TEMP_PATH . $file_name;
|
$file_path = self::DOWNLOAD_TEMP_PATH . $file_name;
|
||||||
$file = file_get_contents($url);
|
$opts = [
|
||||||
|
'http' => [
|
||||||
|
'method' => 'GET',
|
||||||
|
'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$context = stream_context_create($opts);
|
||||||
|
$file = file_get_contents($url, false, $context);
|
||||||
$dir = dirname($file_path);
|
$dir = dirname($file_path);
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
mkdir($dir, 0777, true);
|
mkdir($dir, 0777, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user