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

Differece in MimeType detection #19

Closed
Kkomkov opened this issue Nov 17, 2017 · 5 comments
Closed

Differece in MimeType detection #19

Kkomkov opened this issue Nov 17, 2017 · 5 comments

Comments

@Kkomkov
Copy link

Kkomkov commented Nov 17, 2017

There is difference in MimeType detection for file and byte array for the same file

FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
byte[] ImageData = new byte[fs.Length];
fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));

var res = MimeGuesser.GuessFileType(ImageData);
var res2 = MimeGuesser.GuessFileType(filePath);

check for *.docx files.

@Kkomkov Kkomkov changed the title Different MimeType detection Differece in MimeType detection Nov 17, 2017
@hey-red
Copy link
Owner

hey-red commented Nov 17, 2017

Try to increase buffer size(default 512). I think default size is too small for docx detection.
For example:
MimeGuesser.GuessFileType(ImageData, ImageData.Length);

@Kkomkov
Copy link
Author

Kkomkov commented Nov 18, 2017 via email

@Kkomkov
Copy link
Author

Kkomkov commented Nov 21, 2017

Grate, it works. Thank you.

@Kkomkov Kkomkov closed this as completed Nov 21, 2017
@hey-red
Copy link
Owner

hey-red commented Dec 28, 2017

@Kkomkov Now in 3.0 it default behavior.
You should use:
MimeGuesser.GuessFileType(ImageData);

@Kkomkov
Copy link
Author

Kkomkov commented Dec 30, 2017 via email

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