magic_bytes
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

magic_bytes

Guesses the file type using file signatures (magic bytes).

In Rust

Cargo.toml

[dependencies]
magic_bytes = "0.1.0"

main.rs

use magic_bytes::guess_extension;
 
let mut f = File::open("foo.pcap")?;
let mut buffer = Vec::new();
 
// read the whole file
f.read_to_end(&mut buffer)?;
 
let ext = guess_extension(&buffer); // Extension::Pcap

In JS

npm i magic_bytes
const magic_bytes = import('./pkg');
 
let myFile = []; // some file as bytes
magic_bytes
  .then(m => m.guess_extension(myFile))
  .catch(console.error);

Readme

Keywords

none

Package Sidebar

Install

npm i magic_bytes

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

30.2 kB

Total Files

5

Last publish

Collaborators

  • teovoinea