-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PRO-2191 download #3
Conversation
PRO-2191 As an editor, once my export file has been generated it will automatically start downloading for me
This is a front-end task for presenting the generated file to the user to be downloaded. A separate ticket exists for the actual handling of the export process. Acceptance criteria:
See below for a design with the relevant notifications, once the "Export complete" notification is sent, the browser should prompt the user to download the file automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need content-disposition here, let me know if I'm wrong. Maybe we don't simply because none of the output formats are native to the browser anyway, but it's a good idea to specify downloading is the intent.
@@ -126,8 +126,26 @@ module.exports = (self) => { | |||
return reject(error); | |||
} | |||
|
|||
const downloadUrl = self.apos.attachment.uploadfs.getUrl() + downloadPath; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really get a download this way across browsers with just _blank
? I would think you would need to use a route that sends with with Content-Disposition: Attachment
(I think I sent you the 2.x route we use for it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only one I see that does not download is Safari, which opens the CSV as text in a new tab. This is essentially the way we handled it in the A2 version. https://github.com/apostrophecms/apostrophe-pieces-export/blob/main/public/js/export-modal.js#L39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're saving the file to the public directory I'm not sure how much we get out of putting it behind another route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the A2 version we used a route to download it and that route emits the right Content-Disposition header, as a result of which I betcha Safari doesn't show it in a tab.
(In A3 this would need to be in
|
In A2 that route is in core, as there can be other applications for reliably downloading rather than viewing an attachment, which I think is still the case. |
By that I meant it's how it was done in the pieces export module. |
No description provided.