How to verify File is Archive or not using Magento 2.

Check Given file is an archive or not using Magento 2 by Magento\Framework\Archive Class.

Archive class has a logic to verify the given file is an archive or not in Magento 2.

The archive file gives results as a boolean based on the file extension.

If the file contains a given list of path extensions, it will return true otherwise return false.

Valid Path extension for the file to consider as an archive,

If filename is test.zip, it’s not considered as an archive.
If filename is test.tar, test.tar.gz, test.bz, test.gz, its valid archive file.

You need to pass the absolute path of the archive file to the isArchive() function to verify your file is an archive or not using Magento 2.

You can verify the archive file with passing filename to the above method and will return a response as boolean if the file is a valid archive.