
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
file-type-mime
Advanced tools
Utility to parse mime type from a file content.
Browser (react)
import { parse } from 'file-type-mime';
export default function fileUpload() {
async function onChange(e) {
const [file] = e.target.files;
const buffer = await file.arrayBuffer();
const result = parse(buffer);
console.log('MIME_TYPE', result);
}
return (
<form>
<input type="file" onChange={onChange}>
</form>
);
}
Node.js
import { parse } from "file-type-mime";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
const file = resolve("./path/to/file.pdf");
const buffer = readFileSync(file);
const result = parse(buffer);
console.log("MIME_TYPE", result);
function parse(buffer: ArrayBuffer, options: Options = {}): Result | undefined
Type: ArrayBuffer
A buffer representing file data
Type: { extra?: boolean; hint?: { ext?: string; mime?: string } }
Type: { ext: string; mime: string } | undefined
(more to come...)
File extension | Content (mime) type |
---|---|
bmp | image/bmp |
gif | image/gif |
ico | image/x-icon |
jpg | image/jpeg |
heic | image/heic |
png | image/png |
tiff | image/tiff |
application/pdf | |
rtf | application/rtf |
epub | application/epub+zip |
gz | application/gzip |
jar | application/java-archive |
zip | application/zip |
bz2 | application/x-bzip2 |
rar | application/x-rar-compressed |
tar | application/x-tar |
docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
opd | application/vnd.oasis.opendocument.presentation |
ods | application/vnd.oasis.opendocument.spreadsheet |
odt | application/vnd.oasis.opendocument.text |
db | application/vnd.sqlite3 |
7z | application/x-7z-compressed |
avi | video/x-msvideo |
mp3 | audio/mp3 |
mp4 | video/mp4 |
oga | audio/ogg |
ogg | audio/ogg |
ogm | video/ogg |
ogv | video/ogg |
ogx | application/ogg |
wav | audio/wav |
woff | font/woff |
woff2 | font/woff2 |
deb | application/x-deb |
flac | audio/x-flac |
psd | image/vnd.adobe.photoshop |
wasm | application/wasm |
webp | image/webp |
class | application/java-vm |
exe | application/x-msdownload |
parquet | application/vnd.apache.parquet |
json | application/json |
txt | text/plain |
vsix | application/vsix |
mov | video/quicktime |
afiv | image/avif |
m4v | video/x-m4v |
m4a | audio/mp4 |
FAQs
Utility to parse mime type from a file content
The npm package file-type-mime receives a total of 9,424 weekly downloads. As such, file-type-mime popularity was classified as popular.
We found that file-type-mime demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.