Add ability to download and display files from the controller
See original GitHub issueIs 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:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That’s fair. I like it
@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