mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
Add FileUtil#getContentType().
This commit is contained in:
@@ -16,6 +16,16 @@ object FileUtil {
|
||||
}
|
||||
}
|
||||
|
||||
def getContentType(name: String, bytes: Array[Byte]): String = {
|
||||
defining(getMimeType(name)){ mimeType =>
|
||||
if(mimeType == "application/octet-stream" && isText(bytes)){
|
||||
"text/plain"
|
||||
} else {
|
||||
mimeType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isImage(name: String): Boolean = getMimeType(name).startsWith("image/")
|
||||
|
||||
def isLarge(size: Long): Boolean = (size > 1024 * 1000)
|
||||
|
||||
Reference in New Issue
Block a user