Skip to content

Conversation

@kinelski
Copy link
Contributor

Summary

The new TryGetContentType extension method searches through the first set of bytes of a given stream and compares it to well-known file signatures in order to figure out its content type. This method call can be avoided by the developer when the ContentType property in RecognizeOptions has its value defined and not null.

Changes

  • Creation of StreamExtensions file to include the new TryGetContentType method.
  • Addition of the ContentType property to RecognizeOptions.
  • FormRecognizerClient methods updated to make use of the content type detection.
  • contoso-allinone.png and Invoice_1.tiff files added to the assets folder to help testing the type detection. These files are expected to be used in future tests as well.
  • TestEnvironment class updated to support new files.
  • StreamExtensionsTests class created to test the content type detection.

Fixes #10329
Fixes #11313

@kinelski kinelski added Cognitive Services Client This issue is related to a non-management package FormRecognizer labels Apr 16, 2020
@kinelski kinelski added this to the [2020] May milestone Apr 16, 2020
@kinelski kinelski requested a review from AlexGhiondea as a code owner April 16, 2020 00:39
@kinelski kinelski self-assigned this Apr 16, 2020
Copy link
Member

@annelo-msft annelo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kinelski kinelski merged commit 5984c9a into Azure:master Apr 17, 2020
@kinelski kinelski deleted the fr-detection branch April 17, 2020 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client This issue is related to a non-management package Cognitive - Form Recognizer Cognitive Services

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FormRecognizer] Stop defaulting to PDF when content type detection is in place Auto-detect content-type in streams

5 participants