cdgriffith / puremagic

Pure python implementation of identifying files based off their magic numbers
MIT License
161 stars 34 forks source link

Is it possible to use filehandles / bytestream? #36

Closed martin-thoma closed 2 years ago

martin-thoma commented 2 years ago

I would love to do something like this:

import puremagic

with open(file_path, "rb") as fh:
    ext = puremagic.from_file_handler(fh)

Especially the bytestream support might be nice in case the file is not / cannot / should not be stored on the disk (e.g. AWS Lambda)

cdgriffith commented 2 years ago

puremagic.from_stream(fh) should do what you're looking for!

I def need to update the readme to have the new abilities that people have contributed, sorry about it not being easy to find!

cdgriffith commented 2 years ago

Added quick example to readme with latest release. Thanks for pointing out the omission!