Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use filehandles / bytestream? #36

Closed
martin-thoma opened this issue Oct 14, 2021 · 2 comments
Closed

Is it possible to use filehandles / bytestream? #36

martin-thoma opened this issue Oct 14, 2021 · 2 comments

Comments

@martin-thoma
Copy link

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
Copy link
Owner

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 added a commit that referenced this issue May 14, 2022
@cdgriffith cdgriffith mentioned this issue May 14, 2022
cdgriffith added a commit that referenced this issue May 14, 2022
- Adding generic extension mapping for common file types
- Adding #36 details to readme about magic_stream and magic_string (thanks to Martin)
- Fixing multiple bad extensions and mimetypes
- Removing bad entry for 3gp5 selecting multiple things
@cdgriffith
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants