Level 47
You don't need to download the file, just move it to s3. The file helper with return with the new path
Summer Sale! All accounts are 50% off this week.
Hi!
I'm trying to write a script where I'm trying to move images from an old server to s3. Is it possible to do by downloading the image from an url?
For example.
$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();
}
Please or to participate in this conversation.