Log guessed mime type

pull/194/head
M66B 4 years ago
parent fa05849cb5
commit b250766c1c

@ -141,6 +141,7 @@ public class EntityAttachment {
String getMimeType() { String getMimeType() {
// Try to guess a better content type // Try to guess a better content type
// For example, sometimes PDF files are sent as application/octet-stream // For example, sometimes PDF files are sent as application/octet-stream
// https://android.googlesource.com/platform/libcore/+/refs/tags/android-9.0.0_r49/luni/src/main/java/libcore/net/MimeUtils.java // https://android.googlesource.com/platform/libcore/+/refs/tags/android-9.0.0_r49/luni/src/main/java/libcore/net/MimeUtils.java
// https://blogs.msdn.microsoft.com/vsofficedeveloper/2008/05/08/office-2007-file-format-mime-types-for-http-content-streaming-2/ // https://blogs.msdn.microsoft.com/vsofficedeveloper/2008/05/08/office-2007-file-format-mime-types-for-http-content-streaming-2/
@ -151,6 +152,10 @@ public class EntityAttachment {
if (extension == null) if (extension == null)
return type; return type;
String gtype = Helper.guessMimeType(name);
if (!TextUtils.isEmpty(type) && !type.equals(gtype))
Log.w("Mime type=" + type + " extension=" + extension + " guessed=" + gtype);
extension = extension.toLowerCase(Locale.ROOT); extension = extension.toLowerCase(Locale.ROOT);
// Fix types // Fix types
@ -178,7 +183,6 @@ public class EntityAttachment {
return "application/vnd.ms-powerpoint"; return "application/vnd.ms-powerpoint";
// Guess types // Guess types
String gtype = Helper.guessMimeType(name);
if (gtype != null) { if (gtype != null) {
if (TextUtils.isEmpty(type) || if (TextUtils.isEmpty(type) ||
"*/*".equals(type) || "*/*".equals(type) ||

Loading…
Cancel
Save