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

Extend context.File to allow for the content-dispositon attachments via a new method context.Attachment #1260

Merged
merged 8 commits into from Mar 1, 2019

Conversation

emman27
Copy link
Contributor

@emman27 emman27 commented Feb 27, 2018

Extends the context.File method to allow the Content-Disposition header to be automatically set within this scope. This allows downloads of the file as attachments, allowing the server to specify the filename.

References:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

Resolves #1243

@emman27 emman27 changed the title File attachments Extend context.File to allow for the content-dispositon attachments via a new method context.Attachment Feb 27, 2018
@emman27
Copy link
Contributor Author

emman27 commented Feb 28, 2018

Failure has nothing to do with the PR. Some bad gateway in the vendoring. Could someone trigger a rebuild / look into the bad gateway?

@thinkerou
Copy link
Member

thinkerou commented May 12, 2018

similar #1304 , it's ok, LGTM

@codecov
Copy link

codecov bot commented May 14, 2018

Codecov Report

Merging #1260 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1260      +/-   ##
=========================================
+ Coverage    98.5%   98.5%   +<.01%     
=========================================
  Files          41      41              
  Lines        2070    2073       +3     
=========================================
+ Hits         2039    2042       +3     
  Misses         19      19              
  Partials       12      12
Impacted Files Coverage Δ
context.go 98.37% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2dd3193...0eb1ee5. Read the comment docs.

@thinkerou thinkerou added this to the 1.4 milestone Feb 28, 2019
@thinkerou
Copy link
Member

@appleboy please help to review the pull request, thanks!

@appleboy
Copy link
Member

Before the implementation. I just use the following code.

	c.Header("Content-Description", "Simulation File Download")
	c.Header("Content-Transfer-Encoding", "binary")
	c.Header("Content-Disposition", "attachment; filename="+fileName)
	c.Header("Content-Type", "application/octet-stream")

	c.File(filePath)

@thinkerou thinkerou merged commit ccb9e90 into gin-gonic:master Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants