Skip to content
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

init file download via POST #26155

Closed
wants to merge 6 commits into from
Closed

init file download via POST #26155

wants to merge 6 commits into from

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Mar 16, 2021

Currently file downloads are triggered by a regular GET request through changing the window location. This can leak file names, but also limits the number of downloadable files for URL length restrictions.

~~By switching to a POST request (thus through XHR) we can avoid both aspects. The downside with the chosen method is, that it does not stream the data: the UI is not blocked, but the browser's download progress does not kick in and the save dialog appears only after the file is downloaded. ~~

  • Hence, there is not visual feedback.

Switch to register the download action via POST call that provides all the information. A token is returned, which is then passed along by the GET request through location change. Save dialogue is shown immediately and the browser progress indicator works again, too.

As far as I researched there is no way around with XHR (no stream support by design). Streams API offer support, alas – as far as i know - still would suffer the same problems around the built-in progress bar and save dialog (and cannot be backported for lack of IE support).

Another approach would be to use the progress indicator as with file uploads with downloads, too. But maybe I also oversaw an option?

Now:

  • download on sharing pages is broken
  • tests
  • and the open review remarks

@blizzz
Copy link
Member Author

blizzz commented Mar 16, 2021

An alternative that would keep the browser's download progress would be to announce the download with a post-request, the returns a token, and then trigger the download again by GET but only providing the token as parameter.

@skjnldsv
Copy link
Member

skjnldsv commented Mar 17, 2021

the browser's download progress does not kick in and the save dialog appears only after the file is downloaded.

For me that is a huge issue.
If we do this, like big hosting companies are doing (mega was one of the first), we need to show a progress bar. What if the file is 20GB, will I have to wait for 1h to see the file save dialog?

@PVince81
Copy link
Member

An alternative that would keep the browser's download progress would be to announce the download with a post-request, the returns a token, and then trigger the download again by GET but only providing the token as parameter.

Somehow reminds me of pre-signed download URLs, which are a slightly different thing though.

@blizzz blizzz changed the title download files via POST request init file download via POST Mar 17, 2021
@blizzz
Copy link
Member Author

blizzz commented Mar 17, 2021

An alternative that would keep the browser's download progress would be to announce the download with a post-request, the returns a token, and then trigger the download again by GET but only providing the token as parameter.

This is now implemented.

On smoke testing it of course turned out that sharing needs extra care. There is duplication to some degree, so that's still to tackle.

@blizzz blizzz force-pushed the fix/noid/files-dl-post branch 3 times, most recently from 9878480 to 7c33107 Compare March 31, 2021 10:14
*
*/

import download from './services/Download'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that the service file name is a bit too simple and confusing.
But it's no blocker:

Something like ?

Suggested change
import download from './services/Download'
import download from './services/DownloadFileService'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Just, service is now duplicated (in the path), and what else do you download other than files? It's also actually executing a download. You could argue whether the business logic (register first, then execute), however I think that's an implementation detail here.

- also turns old download php script to Controller
- increases number of possible files for lifting length restrictions in GET data

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- download relevant data is sent per POST, a token is received
- download is started by GET and the received token
- solves the disadvantages from XHR-only download
- job to cleanup download tokens

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@skjnldsv skjnldsv modified the milestones: Nextcloud 22, Nextcloud 23 Jun 2, 2021
@MorrisJobke MorrisJobke removed their request for review July 4, 2021 11:34
@skjnldsv skjnldsv mentioned this pull request Oct 13, 2021
@skjnldsv skjnldsv modified the milestones: Nextcloud 23, Nextcloud 24 Oct 21, 2021
@skjnldsv skjnldsv mentioned this pull request Mar 24, 2022
@blizzz blizzz mentioned this pull request Mar 31, 2022
This was referenced Apr 7, 2022
@blizzz blizzz modified the milestones: Nextcloud 24, Nextcloud 25 Apr 21, 2022
This was referenced Aug 12, 2022
This was referenced Aug 24, 2022
This was referenced Sep 6, 2022
@skjnldsv skjnldsv mentioned this pull request Sep 15, 2022
This was referenced Sep 20, 2022
@blizzz blizzz modified the milestones: Nextcloud 25, Nextcloud 26 Sep 22, 2022
@blizzz blizzz mentioned this pull request Feb 1, 2023
@skjnldsv skjnldsv mentioned this pull request Feb 23, 2023
@blizzz blizzz mentioned this pull request Mar 7, 2023
@blizzz
Copy link
Member Author

blizzz commented Mar 7, 2023

unfinished and not and the table, closing.

@blizzz blizzz closed this Mar 7, 2023
@blizzz blizzz removed this from the Nextcloud 26 milestone Mar 7, 2023
@skjnldsv skjnldsv deleted the fix/noid/files-dl-post branch March 8, 2023 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants