mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 21:15:49 +01:00
(refs #105)Specify suitable Content-Type header for downloaded file.
This commit is contained in:
@@ -93,8 +93,17 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
|
||||
if(raw){
|
||||
// Download
|
||||
contentType = "application/octet-stream"
|
||||
JGitUtil.getContent(git, objectId, false).get
|
||||
val mimeType = FileUtil.getMimeType(path)
|
||||
val bytes = JGitUtil.getContent(git, objectId, false).get
|
||||
|
||||
contentType = if(mimeType == "application/octet-stream" && FileUtil.isText(bytes)){
|
||||
"text/plain"
|
||||
} else {
|
||||
mimeType
|
||||
}
|
||||
//response.setHeader("Content-Disposition", s"inline; filename=${FileUtil.getFileName(path)}")
|
||||
bytes
|
||||
|
||||
} else {
|
||||
// Viewer
|
||||
val large = FileUtil.isLarge(git.getRepository.getObjectDatabase.open(objectId).getSize)
|
||||
|
||||
Reference in New Issue
Block a user