I'm trying to write a script where I'm trying to move images from an old server to Amazon s3. Is it possible to do by downloading the image from an url?
$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();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire