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

File download in POST response #106

Open
castamir opened this issue Oct 7, 2014 · 2 comments
Open

File download in POST response #106

castamir opened this issue Oct 7, 2014 · 2 comments

Comments

@castamir
Copy link

castamir commented Oct 7, 2014

I have a form where user choose to download (or send to email) a subset of financial statement documents.

If user choose send to email, everything is fine, but if he picks download, then no file is downloaded (without ajax, file is downloaded successfully).

If I modify form signal to use redirect where I use the same way i did in the form signal (sending FileResponse), then it allows me to download that file, but spinner stops spinning due to window.location.href in redirect extension. I have experimented and figured out that using window.open() will keep spinner (and all gif animatins) unharmed, but browser's anti-popups alert shows up.

Any ideas for a workaround? I simply need a file download request from within a form with a spinner spinning for each request until requested file is downloaded.

@vojtech-dobes
Copy link
Owner

If I get it right, it's redirect extension that makes trouble to you, right? What about disabling it for that given request with data-ajax-off/settings.off?

@alesmenzel
Copy link

When sending new FileResponse( ... ) from nette, instead of forcing the download of the file, it sends the file represented as a string (see http://prntscr.com/9azo8u).

public function handleDownload() {
   $this->presenter->sendResponse(
   new FileResponse(
      $this->version->getPath()
   ));
}

This works fine without ajax.

Here are sent headers for the ajax request (which i think are correct):

Content-Disposition:attachment; filename="test.rar"; filename*=utf-8''test.rar
Content-Length:1673291
Content-Range:bytes 0-1673290/1673291
Content-Type:application/octet-stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants