Skip to content

Conversation

@bhatman
Copy link

@bhatman bhatman commented Jan 13, 2020

Hi folks,

When using this library, we saw some unexpected behavior when using this library in-line with file uploads. We were passing the file pointer to filetype.guess directly, and then our handler would proceed to upload the file using the same file pointer. Since the pointer is not reset after filetype.guess runs, we were seeing truncated files. Wanted to raise this potential usage issue and offer this patch as a suggestion.

Otherwise, we've found this library to be super useful and easy to use, many thanks for your work on it.

@DanielSwain
Copy link
Contributor

I also encountered this issue when testing a file being uploaded in a validator. If more than one call is made to the filetype API on the same upload, then subsequent calls after the first start at the current pointer position in the buffer. @bhatman I would be interested in an explanation of why you chose the approach you've PRed rather than just obj.seek(0) before the existing obj = obj.read(_NUM_SIGNATURE_BYTES). I've also found this library to be very useful.

SalehDehqanpour pushed a commit to SalehDehqanpour/filetype.py that referenced this pull request Dec 23, 2020
SalehDehqanpour pushed a commit to SalehDehqanpour/filetype.py that referenced this pull request Dec 24, 2020
@bhatman bhatman closed this by deleting the head repository Jan 4, 2023
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

Successfully merging this pull request may close these issues.

2 participants