You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defmaybe_a_fileiferror?# File doesn't exist - render a turbo-stream to display an error messagereturnrender"error_message"endredirect_to"/actual_file.txt"end
Click the link (when error? returns false)
Expected behaviour
The redirect is followed, and the browser downloads and saves actual_file.txt
Actual behaviour
The redirect is followed, the browser requests actual_file.txt, and the server responds 200 OK with the contents of the file; but the file is not saved by the browser
Cause
Via git bisect, determined to be caused by #968 (thanks to @pythonandchips for digging)
Workaround
Instead of server-side redirecting to the file, return a turbo-stream action to visit the actual file URL in JS (both Turbo.visit and window.location.assign work fine)
The text was updated successfully, but these errors were encountered:
If you mark a link with data-turbo-stream, Turbo performs a Turbo stream action, not a download. I suggest implementing this with a Turbo frame. Follow the link, if it doesn't find it, replace the Turbo frame with an error message, and if it finds it you can download the file.
Steps to reproduce
Have HTML containing:
Backed by server code:
Click the link (when
error?
returns false)Expected behaviour
The redirect is followed, and the browser downloads and saves
actual_file.txt
Actual behaviour
The redirect is followed, the browser requests
actual_file.txt
, and the server responds 200 OK with the contents of the file; but the file is not saved by the browserCause
Via
git bisect
, determined to be caused by #968 (thanks to @pythonandchips for digging)Workaround
Instead of server-side redirecting to the file, return a turbo-stream action to visit the actual file URL in JS (both
Turbo.visit
andwindow.location.assign
work fine)The text was updated successfully, but these errors were encountered: