private String typeOfBytes(byte[] bytes) {
    if (bytes.length >= 2) {
      if (bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xD8) {
        return "jpg";
      } else if (bytes[0] == (byte) 0x89 && bytes[1] == (byte) 0x50) {
        return "png";
      } else if (bytes[0] == (byte) 0x52 && bytes[1] == (byte) 0x49) {
        return "webp";
      } else if (bytes[0] == (byte) 0x47 && bytes[1] == (byte) 0x49) {
        return "gif";
      }
    }
    return "undefined";
  }
Creates the directory (and its parents, if necessary). In case of an exception, log an error
message with the relevant parameters

@param directory the directory to create
@param message message to use
@throws IOException
imagepipeline-base/src/main/java/com/facebook/cache/disk/DefaultDiskStorage.java