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

Support Content-Disposition attachment response downloads for server/remote files. #19

Open
arivera12 opened this issue Aug 4, 2020 · 0 comments
Assignees
Labels
blazor server This is related to blazor server side blazor wasm This is related to blazor client side enhancement New feature or request

Comments

@arivera12
Copy link
Owner

arivera12 commented Aug 4, 2020

Problem

When downloading a file from a server directly to JavaScript or Blazor the browser has it's own memory and hardware limitations.

Solution

We should use Content-Disposition attachment response header as it has more cross-browser compatibility.

When using Content-Disposition attachment response header the backing store that the browser uses its the local disk.

This way we will bypass the limitations of the Max File Size of JavaScript and Blazor.

Brainstorming

To make this work with seamless integration we would need to create a JavaScript function which:

  1. Creates dynamic blank window
  2. Creates a dynamic form inside the new window with
    1. action="specified url"
    2. method="specified method"
    3. enctype="specified encode type"
  3. Creates dynamic hidden inputs if an object is provided as argument
  4. Submits the form in that window to the specified url
  5. File download process within the browser should get triggered automatically

Not sure if I am missing something else but this should trigger the file download process within the browser provider and no data should be loaded into memory to JavaScript or Blazor and go straight to the device local disk instead.

Why not an iframe and a window instead?

Iframe will only work on sites that are on the same domain or sites with Access-Control-Allow-Origin response header

If neither of them are considered or present we will hit for sure the same-origin policy error.

Authorization Header

Authorization tokens may be passed down to the new window and form as an input value to be submitted with the rest of the other inputs values.

AFAIK there is no way to pass down authorization token in a header when submitting a form or sending cross domain cookies.

Sample references

https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_open3
https://gist.github.com/carlosrivera/768b0c14e083c1ab423f

@arivera12 arivera12 added enhancement New feature or request blazor server This is related to blazor server side blazor wasm This is related to blazor client side labels Aug 4, 2020
@arivera12 arivera12 self-assigned this Aug 4, 2020
@arivera12 arivera12 changed the title Enhancement: Support Content-Disposition attachment response downloads for server files. Enhancement: Support Content-Disposition attachment response downloads for server/remote files. Aug 4, 2020
@arivera12 arivera12 changed the title Enhancement: Support Content-Disposition attachment response downloads for server/remote files. Support Content-Disposition attachment response downloads for server/remote files. Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blazor server This is related to blazor server side blazor wasm This is related to blazor client side enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant