fun getContentType()

in google-storage-agent/src/main/kotlin/jetbrains/buildServer/artifacts/google/publish/GoogleFileUtils.kt [51:68]


    fun getContentType(file: File): String {
        URLConnection.guessContentTypeFromName(file.name)?.let {
            return it
        }

        if (probeContentTypeMethod != null && fileToPathMethod != null) {
            try {
                probeContentTypeMethod.invoke(null, fileToPathMethod.invoke(file))?.let {
                    if (it is String) {
                        return it
                    }
                }
            } catch (ignored: Exception) {
            }
        }

        return DEFAULT_CONTENT_TYPE
    }