fightstarr20
fightstarr20

Reputation: 12618

Laravel 5.6 - Upload stored file to S3

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?

Upvotes: 1

Views: 2818

Answers (2)

MaleihMaxime
MaleihMaxime

Reputation: 63

After adding use Illuminate\Support\Facades\Storage;

You can do it like this:

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

File System Laravel

Upvotes: 0

Salman Zafar
Salman Zafar

Reputation: 4035

You can do it like this:

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

File System Laravel

Upvotes: 2

Related Questions