I want to get file type of the file on provided URL. If is it a GIF file, I need to know that.
Example URL : https://media3.giphy.com/avatars/100soft/WahNEDdlGjRZ.gif (it may not always include a file extension)
Get the InputStream from the URL to a
Most solutions will have you reading the whole stream, but that's not completely necessary because you only need to check the first three bytes.
All GIF files must start with a header block. The header takes up the first six bytes of the file. These bytes should all correspond to ASCII character codes. The first three bytes are called the signature. These should always be "GIF" (ie 47="G", 49="I", 46="F")