exsnake
exsnake

Reputation: 1823

Laravel Storage rename file before downlaod

I want to rename a file in the moment before download it in Laravel 8.0:

I currently using the following code:

$link = Storage::cloud()->download($request->input('document'));

But I can't find a way to rename it before download it. I don't want to rename the file in S3.

Upvotes: 1

Views: 1589

Answers (2)

Mustafa Poya
Mustafa Poya

Reputation: 3027

You can do it as below: Second parameter is return file name Third parameter add header info to your file

return response()->download(storage_path($path), 'new name.extension', array('content-description'=> 'description'));

Upvotes: 1

Vision Coderz
Vision Coderz

Reputation: 8078

You can pass second argument to download method as below

$link = Storage::cloud()->download($request->input('document'),"newfilename.extension");

Upvotes: 3

Related Questions