First basic version will have an interface where the user will provide the expected extension by giving the mime type. The signatures are fetched based on this mime type by fetching the entire list of extensions and figuring out the starting and trailing bytes.
Later versions may contain absolute checking based on the extension of the file fetched from the filename and the actual extension based on magic number.
The steps for validation are this: (version 0.1)
- Get the extension,
- Figure out the list of hexcodes,
- Get the sizes of the hexcodes and get the GCD,
- Use the GCD to read that many bytes from the file provided,
- Check to see if the bytes from the file correspond with the hexcodes,
- Return true or false.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install filemagick
TODO: Write usage instructions here
- Fork it ( https://github.com/[my-github-username]/filemagick/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request