2017-03-28 27 views
1

我正在嘗試編寫腳本,試圖將圖像從舊服務器移動到Amazon s3。是否可以通過從url下載圖像來完成?將圖像從一臺服務器移動到s3 PHP Laravel 5.3

$companies = Company::all(); 

$companies->each(function ($company) { 

    //some method to download file 
    $file = download($company->logo); 

    //Store on s3 
    $filename = $file->storeAs('images', uniqid('img_') . "." . $file->guessClientExtension(),'s3'); 

    //Get the new path 
    $new_path = Storage::disk('s3')->url($filename); 

    //save the new path to logo 
    $company->logo = $new_path; 

    //save the new path 
    $company->save(); 
} 
+0

是的,使用curl/guzzle或編寫腳本來通過ssh移動圖像 – Indra

回答

0

你可以使用這個庫Php League FileSystem

它有laravel和其他framewoks,比如Zend的整合,蛋糕等

圖書館有亞馬遜S3 V2和Amazon S3的V3

適配器

完整文檔here

相關問題