Created
December 5, 2022 09:44
-
-
Save piemme/a149c8348f6b324da9e183fb9244c3c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {fileTypeFromStream} from 'file-type'; | |
const url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg'; | |
const response = await fetch(url); | |
const fileType = await fileTypeFromStream(response.body); | |
console.log(fileType); | |
//=> {ext: 'jpg', mime: 'image/jpeg'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment