Closed ctunon-align closed 5 months ago
I'll have to refuse this PR. I'm not sure about exposing more APIs. There is an issue that might bite library users and I would like fixing it before adding more functions. I have a rough idea how to proceed, but I just didn't have the time for it.
In the meantime I think something like this can solve your problem:
shortRead := 3000
longRead := 10*shortRead
mimetype.SetLimit(longRead)
mime, _ := mimetype.DetectReader(io.LimitReader(r, shortRead))
if mime.Is("application/x-ole-storage") {
mime, _ := mimetype.DetectReader(io.LimitReader(r, longRead))
}
Totally understandable. Thank you so much for providing a workaround tho. Wasn't aware of that io.LimitReader.
Hello!
Im currently using this library in a server and stumbled upon the issue about the msword files being detected as x-ole-storage files due to them having the file type signature at the end. The SetLimit function seems to be modifying a global limit variable. Since I want to avoid reading the whole file if I dont need to, I added a struct to hold a separated limit.
I would like to be able to do stuff like this: