Skip to content

Instantly share code, notes, and snippets.

@Isxida
Created October 9, 2013 23:20
Show Gist options
  • Save Isxida/6910246 to your computer and use it in GitHub Desktop.
Save Isxida/6910246 to your computer and use it in GitHub Desktop.
private String getMimeFromByte(byte[] src) {
if (src[0] == 0x25 && src[1] == 0x50 && src[2] == 0x44 && src[3] == 0x46) {
return "application/pdf";
}
if (src[0] == 0x50 && src[1] == 0x4b) {
return "application/zip";
}
if (src[0] == 0xd0 && src[1] == 0xcf && src[2] == 0x11 && src[3] == 0xe0 && src[4] == 0xa1 && src[5] == 0xb1 && src[6] == 0x1a && src[7] == 0xe1) {
return "application/vnd.ms-powerpoint";
}
return "application/octet-stream";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment