I know how to upload file from local storage to aws using laravel. But I want to upload file directly from external url to aws without downloading.
Any suggestion, how can I achieve this.
I know how to upload file from local storage to aws using laravel. But I want to upload file directly from external url to aws without downloading.
Any suggestion, how can I achieve this.
I finally solved this using Intervention Image Library.
use Image;
use Storage;
$image = Image::make('url');
$image->encode('jpg');
$s3 = Storage::disk('s3');
$filePath = '/profilePhotos/'.$time();
$s3->put($filePath, $image->__toString(), 'public');
Installation instructions for Image library can be found here in the "Integration in Laravel" section.
The accepted answer is dependent on another library. You can do it without the Intervention Image Library. Here is how you can do it-
$url = 'https://remote.site/photo/name.jpg'
$contents = file_get_contents($url);
$name = substr($url, strrpos($url, '/') + 1);
Storage::put($name, $contents);