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
)
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.
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 :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community