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

set attachment filename when download through browser #728

Merged
merged 2 commits into from
May 14, 2023

Conversation

wunter8
Copy link
Contributor

@wunter8 wunter8 commented May 14, 2023

Fixes #726

@codecov-commenter
Copy link

codecov-commenter commented May 14, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (bd81aef) 66.34% compared to head (028f3aa) 66.41%.

❗ 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     
Impacted Files Coverage Δ
server/server.go 61.91% <100.00%> (+0.23%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -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))
}
Copy link
Owner

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?

Copy link
Contributor Author

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

Copy link
Owner

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....

Copy link
Contributor Author

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

Copy link
Owner

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.

Copy link
Owner

@binwiederhier binwiederhier May 14, 2023

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.

@binwiederhier binwiederhier merged commit 8f87e90 into binwiederhier:main May 14, 2023
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

Successfully merging this pull request may close these issues.

Port missing in URL for "send notification" via web gui / attachement
3 participants