Data export doesnt work on Safari

Created on 31 December 2019, over 4 years ago
Updated 16 November 2023, 8 months ago

I created a view data export display that worked on chrome browser but was not exporting the data in safari. I debugged it further and realised that it worked only when the file name was specified in the path settings. If we dont specify the filename the csv data gets printed on the screen and file doesnt download

Steps to reproduce:
- Create a new view data export display which would export a CSV file
- In the path settings don't specify the file name
- Try exporting the csv file in chrome and safari.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India ameymudras

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    3 pass
  • 🇧🇾Belarus dewalt

    The issue takes place when export files are stored to the private location. Hook "hook_file_download()" allows add headers to private files. Patch below adds the hook to the module. Also with this change JSON download also works in Safari.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 8 months ago
    3 pass
  • 🇧🇾Belarus dewalt

    I'm not sure what encoding is needed for filename inside of "Content-disposition" header, in Chrome and Safari it works with backslashes, URL encode and plane, even if filename has quotes. So I keep it plain, same to implementation in the module in DataExport::buildStandard()

  • 🇺🇸United States maskedjellybean Portland, OR

    I have this problem but I'm not using the private file system (only public), so the patch doesn't help me. I tried the event subscriber in #3, and while it did work, it seems a little overbearing to run that if statement on every page request across the site on the off chance that the request contains "csv". Adding to .htaccess as suggested in #2 didn't work for me.

    In the end I did what was suggested by the reporter: Set the file name in the views path settings.

    This is a bug for sure, but at least it's easily worked around.

Production build 0.69.0 2024