-
Notifications
You must be signed in to change notification settings - Fork 20
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
Avoiding the consumption of InputStream when detecting mime type? #20
Comments
@iku000888 that makes sense, please submit a PR that does that (using 100% Java interop if this is what you're most familiar with, that's fine). |
Given that nobody has messed with input stream mark, |
I've used it in one of the project - it mostly worked, maybe except very big files, like big Zips, or something like - can't remember right now... |
@michaelklishin Thanks for the feedback! Here is a bit more of investigation results before I form a PR. Maybe there could be a suggestion to the user to coerce the input stream instead? ;stream is consumed
user> (let [stream (java.io.FileInputStream. "project.clj")] [(mime-type-of stream) (mime-type-of stream)])
["text/plain" "application/octet-stream"]
;stream is not consumed
user> (let [stream (clojure.java.io/input-stream "project.clj")] [(mime-type-of stream) (mime-type-of stream)])
["text/plain" "text/plain"] |
@iku000888 as long as the result is an |
Thank you for the wonderful library that works like a charm.
While using this I did notice that when detecting the mime type from an InputStream instance,
the bytes get consumed and I cannot simply reuse the same object.
There are work arounds available (mostly Java), and that is what InputStreams do,
but it would be nice if mime-type-of is free of side effects (at least from the app developer perspective).
Thanks!
P.S. Would greatly appreciate any recommended methods for re-using InputStream instances.
The text was updated successfully, but these errors were encountered: