1
votes

I have a Laravel 5.6 project which has images stored using the Storage facade.

I am trying to take an image that I have stored and move it to S3 storage like this..

$contents = Storage::disk('local')->url($image->filename);
$storagePath = Storage::disk('s3')->put("uploads", $contents, 'public');

This uploads a file to the S3 bucket called 'uploads' that contains the path to the file like this...

/storage/myimage.jpg

How can I upload the actual file instead of saving the path?

2
Change ->url() to ->get() and you will have the contents of the file.Ohgodwhy
This is all in the docs... laravel.com/docs/5.6/filesystem#file-uploadsLoek

2 Answers

2
votes

You can do it like this:

$contents = Storage::get('file.jpg');

File System Laravel

0
votes

After adding use Illuminate\Support\Facades\Storage;

You can do it like this:

$contents = Storage::get('file.jpg');

File System Laravel