Skip to content

Action::downloadURL uses action name for filename #6318

@miagg

Description

@miagg
  • Laravel Version: 11.1.0
  • Nova Version: 4.33.1
  • PHP Version: 8.3.3
  • Database Driver & Version:
  • Operating System and Version: macOS Sonoma 14.4.1
  • Browser type and version: Chrome 133

Description:

When using static action Action::downloadURL, the name parameter is also used for the downloaded filename. This in most cases is undesired behavior. We need a way to either have the actual filename (no download value on vue component) or add a third optional argument on the function to use for the filename.

To Reproduce

Action::downloadURL('Download QR Code (SVG)', fn(Elabel $elabel) => $elabel->qr_svg_url)
    ->sole()->withoutConfirmation();

Downloads file as Download QR Code (SVG).svg

Temporary Workaround (No dynamic name though using model)

Action::downloadURL("qrcode.svg", fn(Elabel $elabel) => $elabel->qr_svg_url)
    ->withName('Download QR Code (SVG)')
    ->sole()->withoutConfirmation(),

Downloads file as qrcode.svg
Since name argument does not accept a callback, we can't name the file dynamically.

Suggestions

Desired behavior

Action::downloadURL('Download QR Code (SVG)', fn(Elabel $elabel) => $elabel->qr_svg_url)
    ->sole()->withoutConfirmation();

Downloads file as ak93js0d.svg (actual url filename)

Optionally

Action::downloadURL(
    'Download QR Code (SVG)', 
    fn(Elabel $elabel) => $elabel->qr_svg_url,
    fn(Elabel $elabel) => "{$elabel->uid}.svg"
)->sole()->withoutConfirmation();

Downloads file as ak93js0d.svg
Third argument needs to be string|Closure

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions