-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
set attachment filename when download through browser #728
set attachment filename when download through browser #728
Conversation
Codecov ReportPatch coverage:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## main #728 +/- ##
==========================================
+ Coverage 66.34% 66.41% +0.06%
==========================================
Files 48 48
Lines 6873 6875 +2
==========================================
+ Hits 4560 4566 +6
+ Misses 1601 1599 -2
+ Partials 712 710 -2
☔ View full report in Codecov by Sentry. |
@@ -642,6 +642,9 @@ func (s *Server) handleFile(w http.ResponseWriter, r *http.Request, v *visitor) | |||
return err | |||
} | |||
defer f.Close() | |||
if m.Attachment.Name != "" { | |||
w.Header().Set("Content-Disposition", "attachment; filename="+strconv.Quote(m.Attachment.Name)) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, ... This changes the default browser behavior, right? Will images be downloaded too, or just things that are normally downloaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything will download automatically if you go directly to the URL, including images. When would you go to the URL and not want to download it? Just to see a bigger version of the image?
We could add a condition based on content type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the web app embeds images. I am not sure if there are other use cases, but I'd say it's safe to say we'll want to inline display images at least. Hm....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 90% sure the embedded/inline images worked just fine in the web app when I tested it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. Maybe the browser does the right thing. I'll test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works indeed. Tested Firefox and Chrome.
Fixes #726