Support the ongoing development of Laravel.io →
Laravel Eloquent Laravel.io

recently i am having problem in downloading files using storage disk('s3') in laravel . I can download file using export.php but i need to convert it to use s3, for which i can't find help on chrome .Here is my code.

 if ($request->download && !is_null($data)) {

$array = json_decode( json_encode($data), true);	

$final_array = [];

foreach($array as $key){

unset($key['id']);

array_push($final_array,$key);	

}

$keys = array_keys(($final_array[0]));

$file_name = 'Today_Delivery_'.$request->user()->id.'_'.Carbon::now()->format('d_M_Y_His').'.xlsx';

(new GenDataExport(collect(json_decode(json_encode($final_array), true)), $keys ))-store($file_name);

// $s3 = \Storage::disk('s3');

// $filePath = '/users/signatures'.'/'.$user_id.'/post-'.$customer_id.'_'.$imageFileName;

// $s3->put($filePath, file_get_contents($image), 'public');

// $url = config('filesystems.disks.s3.arn_url');

}

As you can see the file is downloading by export.php file and i want to use the commented code to download it , but can't think where to use that code .Any help will be appreciated ,Thanks.

i tried but got this error. file_get_contents() expects parameter 1 to be a valid path, array given when i gave $final_array to file_get_contents. Here is my $final_array value

    [0] => Array
        (
            [customer_name] => doodh walah
            [area] => no area
            [product_name] => milk bill
            [address] => 
            [qty] => 1
        )

    [1] => Array
        (
            [customer_name] => doodh walah
            [area] => no area
            [product_name] => milk
            [address] => 
            [qty] => 1
        )
Last updated by @tvbeek 1 year ago.
0

nice, can't demonstrate my code as code ,no matter how much i try.Can't show code like this array did my best to show.

Last updated by @tejsingh199 1 year ago.
0
moderator

Hello @tejsingh199

The only file_get_contents is see use the variable $image. But I didn't see where you set that variable, can you show it?

Ps. I have updated your post to have the code blocks :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Tej Singh tejsingh199 Joined 11 Dec 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.