作者 lyh

gx

... ... @@ -9,6 +9,7 @@
namespace App\Console\Commands\Test;
use App\Models\File\File;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -41,11 +42,18 @@ class ProductFileUpload extends Command
$project_id = $this->argument('project_id');
ProjectServer::useProject($project_id);
$productModel = new Product();
$lists = $productModel->list(['status'=>1,'id'=>['<=',109]]);
$lists = $productModel->list(['status'=>1,'id'=>['<=',106]]);
foreach ($lists as $k => $v){
if(!empty($v['files']) && !empty($v['files']['url'])){
$url = str_replace_url($v['files']['url']);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
//获取当前图片的原名称
$files = new File();
$fileInfo = $files->read(['url'=>$url]);
if($fileInfo === false){
continue;
}
$newName = rtrim($url, '/').'/'.$fileInfo['name'];
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($newName, true) . PHP_EOL, FILE_APPEND);
}
}
DB::disconnect('custom_mysql');
... ... @@ -58,11 +66,11 @@ class ProductFileUpload extends Command
* @method :post
* @time :2024/4/8 11:10
*/
public function synchronizationFile($path_name){
public function synchronizationFile($path_name,$newName){
//同步到大文件
$file_path = config('filesystems.disks.cos')['cdn1'].$path_name;
$directoryPath = pathinfo($path_name, PATHINFO_DIRNAME);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$directoryPath.'" https://v6-file.globalso.com/upload.php';
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$newName.'" https://v6-file.globalso.com/upload.php';
return shell_exec($cmd);
}
}
... ...