question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to download and display files from the controller

See original GitHub issue

Is your feature request related to a problem? Please describe. We need to be able to download files from the web. We may do something like generate PDF’s and then need to be able to force that download (or display it in the browser)

What do we currently have to do now? We simply cannot do it now

Describe the solution you’d like We need something like this in the controller:

from masonite.helpers import Download

def show(self):
     return Download('/some/file.pdf')

This will display it properly in the browser. We should also be able to force the download:

from masonite.helpers import Download

def show(self):
     return Download(open('/some/file.pdf'), force=True)

or

from masonite.helpers import Download

def show(self):
     return Download('/some/file.pdf').force()
  • Is this a breaking change?

Additional context This will entail moving away from compiling everything to string (and then bytes at the end) to converting everything to bytes.

This will also require a change to the start.py file.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
josephmancusocommented, Nov 16, 2019

That’s fair. I like it

0reactions
josephmancusocommented, Nov 25, 2019

@girardinsamuel I think if we go that route we would need to open a dedicated issue for that but I think we should approach something like that in the near feature. Preferably after 2.3 is released. Since this is staged in 2.3 I’ll close this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Downloading a file from spring controllers - java
This code is working fine to download a file automatically from spring controller on clicking a link on jsp. @RequestMapping(value="/downloadLogFile") ...
Read more >
Uploading and Downloading in MVC Step-by-Step
This article explains how to upload and download files in MVC, step-by-step. ... Let us start with creating a controller called "myAction".
Read more >
Spring MVC Download File Controller Example
Spring MVC download file controller example. Learn to download a file in Spring MVC application and prevent cross referencing.
Read more >
How to upload and download files from a remote server in ...
This code sample demonstrates how to upload and download files from a remote or local server in ASP.NET. You can download the sample...
Read more >
Download Files in ASP.NET MVC 3 using Controller Action
Step 1: Open VS2010 and create a new ASP.NET MVC 3 project, name it as 'MVC3_Returning_Files'. Step 2: In the project, add a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found