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

[omm][api] Hash api to detect content type #1359

Merged
merged 1 commit into from
Sep 14, 2023
Merged

Conversation

Dcallies
Copy link
Contributor

Summary

Followups from #1355 suggested by @dougneal

Test Plan

$ curl 'localhost:5000/h/hash?' \
  'url=https://github.com/facebook/ThreatExchange/blob/main/pdq/data/bridge-mods/aaa-orig.jpg?raw=true'
{
  "pdq": "f8f8f0cee0f4a84f06370a22038f63f0b36e2ed596621e1d33e6b39c4e9c9b22"
}
$ curl 'localhost:5000/h/hash?' \
  'url=https://github.com/facebook/ThreatExchange/raw/main/tmk/sample-videos/chair-19-sd-bar.mp4'
<!doctype html>
<html lang=en>
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>unsupported url ContentType: &#39;application/octet-stream&#39;, if you know the expected type, provide it with content_type</p>
$ curl 'localhost:5000/h/hash?' \
  'url=https://github.com/facebook/ThreatExchange/raw/main/tmk/sample-videos/chair-19-sd-bar.mp4&' \
  'content_type=video'
{
  "video_md5": "0a21c8f85a55a9e276ffc2c53f6887c4"
}

arg = request.args.get("content_type", "")
if not arg:
if url_content_type.lower().startswith("image"):
Copy link
Contributor

Choose a reason for hiding this comment

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

image/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't sure if "image" by itself is a type. I didn't find any comprehensive listing.

@Dcallies Dcallies merged commit 9af70ce into main Sep 14, 2023
4 of 5 checks passed
@Dcallies Dcallies deleted the content_type_detect branch September 14, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants