Skip to content

SixArm.com » Ruby » MagicNumberType infers a data type from the data's leading bytes

License

Notifications You must be signed in to change notification settings

SixArm/sixarm_ruby_magic_number_type

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SixArm.com → Ruby →
MagicNumberType infers mime types from leading bits

Gem Version Build Status Code Climate

Introduction

Magic numbers are the first bits of a file or data stream which uniquely identify the type of file or data stream.

For example when the first bits are "BM", this identifies the file as a bitmap image file.

For docs go to http://sixarm.com/sixarm_ruby_magic_number_type/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_magic_number_type

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_magic_number_type'

Require

To require the gem in your code:

require 'sixarm_ruby_magic_number_type'

Details

This gem infers based on widespread programming conventions for data file formats.

These magic numbers are by convention and we are using this guide: http://www.astro.keele.ac.uk/oldusers/rno/Computing/File_magic.html

Typical uses of magic numbers:

  • to quickly identify a file's data type
  • to check if data matches the file's MIME type or extension
  • to check if a web form file upload matches its HTTP content type

Compare:

Contributors

About

SixArm.com » Ruby » MagicNumberType infers a data type from the data's leading bytes

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published